Gathering detailed insights and metrics for auth0-spa-js
Gathering detailed insights and metrics for auth0-spa-js
Gathering detailed insights and metrics for auth0-spa-js
Gathering detailed insights and metrics for auth0-spa-js
@auth0/auth0-spa-js
Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE
@oqton/auth0-spa-js
Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE
@ctx-core/auth0-spa-solid
Auth0 solid-js components & ctx-core integration for progressive web apps
@afroze9/solid-auth0
A wrapper on top of auth0-spa-js for solidjs.
Auth0 authentication for Single Page Applications (SPA) with PKCE
npm install auth0-spa-js
Typescript
Module System
Node Version
NPM Version
47.4
Supply Chain
91.5
Quality
82.8
Maintenance
100
Vulnerability
99.6
License
TypeScript (59.89%)
JavaScript (31.71%)
HTML (8.4%)
Total Downloads
136,433
Last Day
7
Last Week
564
Last Month
2,207
Last Year
18,974
MIT License
957 Stars
770 Commits
383 Forks
32 Watchers
32 Branches
93 Contributors
Updated on Jul 04, 2025
Minified
Minified + Gzipped
Latest Version
1.6.5
Package Id
auth0-spa-js@1.6.5
Unpacked Size
6.54 kB
Size
2.57 kB
File Count
3
NPM Version
6.4.1
Node Version
8.16.0
Published on
Jan 24, 2020
Cumulative downloads
Total Downloads
Last Day
0%
7
Compared to previous day
Last Week
37.9%
564
Compared to previous week
Last Month
46.8%
2,207
Compared to previous month
Last Year
-6.5%
18,974
Compared to previous year
1
Auth0 SDK for Single Page Applications using Authorization Code Grant Flow with PKCE.
From the CDN:
1<script src="https://cdn.auth0.com/js/auth0-spa-js/1.2/auth0-spa-js.production.js"></script>
Using npm:
1npm install @auth0/auth0-spa-js
Using yarn:
1yarn add @auth0/auth0-spa-js
Create an Auth0Client
instance before rendering or initializing your application. You should only have one instance of the client.
1import createAuth0Client from '@auth0/auth0-spa-js'; 2 3//with async/await 4const auth0 = await createAuth0Client({ 5 domain: '<AUTH0_DOMAIN>', 6 client_id: '<AUTH0_CLIENT_ID>', 7 redirect_uri: '<MY_CALLBACK_URL>' 8}); 9 10//with promises 11createAuth0Client({ 12 domain: '<AUTH0_DOMAIN>', 13 client_id: '<AUTH0_CLIENT_ID>', 14 redirect_uri: '<MY_CALLBACK_URL>' 15}).then(auth0 => { 16 //... 17});
1<button id="login">Click to Login</button>
1//with async/await 2 3//redirect to the Universal Login Page 4document.getElementById('login').addEventListener('click', async () => { 5 await auth0.loginWithRedirect(); 6}); 7 8//in your callback route (<MY_CALLBACK_URL>) 9window.addEventListener('load', async () => { 10 const redirectResult = await auth0.handleRedirectCallback(); 11 //logged in. you can get the user profile like this: 12 const user = await auth0.getUser(); 13 console.log(user); 14}); 15 16//with promises 17 18//redirect to the Universal Login Page 19document.getElementById('login').addEventListener('click', () => { 20 auth0.loginWithRedirect().catch(() => { 21 //error while redirecting the user 22 }); 23}); 24 25//in your callback route (<MY_CALLBACK_URL>) 26window.addEventListener('load', () => { 27 auth0.handleRedirectCallback().then(redirectResult => { 28 //logged in. you can get the user profile like this: 29 auth0.getUser().then(user => { 30 console.log(user); 31 }); 32 }); 33});
1<button id="call-api">Call an API</button>
1//with async/await 2document.getElementById('call-api').addEventListener('click', async () => { 3 const accessToken = await auth0.getTokenSilently(); 4 const result = await fetch('https://myapi.com', { 5 method: 'GET', 6 headers: { 7 Authorization: `Bearer ${accessToken}` 8 } 9 }); 10 const data = await result.json(); 11 console.log(data); 12}); 13 14//with promises 15document.getElementById('call-api').addEventListener('click', () => { 16 auth0 17 .getTokenSilently() 18 .then(accessToken => 19 fetch('https://myapi.com', { 20 method: 'GET', 21 headers: { 22 Authorization: `Bearer ${accessToken}` 23 } 24 }) 25 ) 26 .then(result => result.json()) 27 .then(data => { 28 console.log(data); 29 }); 30});
1<button id="logout">Logout</button>
1import createAuth0Client from '@auth0/auth0-spa-js'; 2 3document.getElementById('logout').addEventListener('click', () => { 4 auth0.logout(); 5});
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
This SDK is in Early Access with selected stakeholders.
We process feedback and provide support via private channels.
For a rundown of common issues you might encounter when using the SDK, please check out the FAQ.
Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
Auth0 helps you to easily:
This project is licensed under the MIT license. See the LICENSE file for more info.
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
SAST tool detected
Details
Reason
6 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 9
Reason
branch protection is not maximal on development and all release branches
Details
Reason
5 existing vulnerabilities detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More