auth0-spa-js

Integrates Auth0 login and logout flows into non-Go, wait, non-JavaScript web apps.

40|23|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/auth0/agent-skills --skill auth0-spa-js
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth0-spa-js
Source: https://github.com/auth0/agent-skills/tree/main/plugins/auth0-sdks/skills/auth0-spa-js
Command: npx skills add https://github.com/auth0/agent-skills --skill auth0-spa-js

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @inquirer/prompts, execa, ora, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Provides step-by-step guidance and automation to add secure authentication to browser-based single-page applications that do not use framework-specific Auth0 wrappers, removing guesswork around client setup, redirect handling, token management, and environment configuration.

Core Features & Use Cases

  • SDK installation guidance for @auth0/auth0-spa-js and guidance for CDN usage when no bundler is present.
  • Client initialization patterns, redirect callback handling, login/logout flows, access token acquisition, and optional refresh token rotation for persistent sessions.
  • Automated bootstrap scripts to create Auth0 SPA clients, update connections, and write environment variables safely, plus testing and troubleshooting checklists for common build and runtime errors.
  • Use case: Add Auth0 to a Vanilla JS or Svelte app, initialize the client from environment variables, handle the OAuth redirect callback, and call a protected API with a silently obtained token.

Quick Start

Initialize the Auth0 SPA JS client using createAuth0Client with your VITE_AUTH0_DOMAIN and VITE_AUTH0_CLIENT_ID environment variables and verify login, logout, and token retrieval.

Frequently Asked Questions about auth0-spa-js

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Auth0 authentication to a vanilla JavaScript SPA?

To add Auth0 authentication to a vanilla JavaScript SPA, install the @auth0/auth0-spa-js package, initialize the client with your environment variables, and implement login, logout, and redirect callback handling. This provides secure browser-based authentication without framework-specific wrappers.

Does Auth0 SPA JS work with Svelte and SolidJS applications?

Yes, Auth0 SPA JS works with Svelte, SolidJS, and other framework-agnostic single-page applications. It provides client initialization, OAuth redirect callback handling, and token management for any non-framework browser-based SPA architecture.

How do I handle OAuth redirect callbacks and get access tokens in a browser SPA?

Handle OAuth redirect callbacks by calling the handleRedirectCallback method after the Auth0 client initializes. This processes the authentication response, establishes the user session, and allows you to acquire access tokens for calling protected APIs.

Can I use refresh token rotation for persistent sessions in an Auth0 SPA?

Yes, you can use optional refresh token rotation in an Auth0 SPA for persistent sessions. This allows your single-page application to silently obtain fresh access tokens without requiring the user to log in again during their session.

Do I need a bundler to install the Auth0 SPA JS SDK?

No, you do not need a bundler to install the Auth0 SPA JS SDK. While you can install it via npm for bundled projects, the SDK also supports direct CDN usage for vanilla JavaScript applications without a build step.

Why are my Auth0 SPA environment variables not loading during client initialization?

Auth0 SPA environment variables may not load if the prefixes do not match your bundler's requirements, such as VITE_ for Vite projects. Verify your environment variable prefixes and use bootstrap scripts to safely write and test configurations.