Skip to main content

AI Prompt

Using AI to integrate Auth0? Add this prompt to Cursor, Windsurf, Copilot, Claude Code or your favourite AI-powered IDE to speed up development.
Prerequisites: Before you begin, ensure you have the following installed:Build Tool: This quickstart uses Vite for development. You can also use the SDK via CDN for a build-tool-free setup.

Get Started

This quickstart shows how to add Auth0 authentication to a vanilla JavaScript application. You’ll create a modern single-page app with secure login functionality using plain JavaScript and the Auth0 SPA SDK.
1

Create a new project

Create a new JavaScript project for this Quickstart
Initialize the project, install a local development server, and configure scripts
Create the basic project structure
2

Install the Auth0 SPA JS SDK

3

Setup your Auth0 App

Next up, you need to create a new app on your Auth0 tenant and add the environment variables to your project.You can choose to do this automatically by running a CLI command or do it manually via the Dashboard:
Run the following shell command on your project’s root directory to create an Auth0 app and generate a .env.local file:
4

Create the HTML structure and application logic

Create the application files:
5

Run your app

CheckpointYou should now have a fully functional Auth0 login page running on your localhost

Advanced Usage

If you need to call a protected API, you can get an access token:
For a smoother user experience, you can use popup-based login:
If you’re using Auth0 Organizations: