Skip to main content
This Quickstart is currently in Beta. We’d love to hear your feedback!

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.

Get Started

This quickstart demonstrates how to add Auth0 authentication to a Cap’n Web application. You’ll build a modern RPC-based web application with secure login functionality using Cap’n Web’s JavaScript framework and the Auth0 SPA SDK.
1

Create a new project

Create a new Cap’n Web project and set up the basic structure:
Initialize the project and configure it for ES modules:
Create the project folder structure:
2

Install dependencies

Install Cap’n Web and core dependencies:
Install the Auth0 SDKs for authentication and token verification:
@auth0/auth0-spa-js is used on the client side to handle user authentication, login flows, and token management in the browser.@auth0/auth0-api-js is used on the server side to verify access tokens and validate JWT signatures using Auth0’s JWKS.
Set up the start script in package.json:
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 file:
5

Create the server

Create the Cap’n Web server with Auth0 integration:
server/index.js
6

Create the client interface

Create the frontend HTML and JavaScript files:
7

Run your app

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

Advanced Usage

Enhance security by adding additional validation and rate limiting to your RPC methods:
server/profile-service.js
Implement proper WebSocket connection handling with automatic reconnection:
client/connection-manager.js
Replace in-memory storage with a database for production use:
server/database.js