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:Verify installation: node --version && npm --versionBuild 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 have three options to set up your Auth0 app: use the Quick Setup tool (recommended), run a CLI command, or configure manually via the Dashboard:
4

Create the HTML structure and application logic

Create the application files:
5

Run your app

If port 5173 is in use, run: npm run dev -- --port 5174 and update your Auth0 app’s callback URLs to http://localhost:5174
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: