Skip to content

Vite + React/Typescript + Auth0, localhost with HTTPS (thanks to vite-plugin-mkcert), alllows auth0 `getAccessTokenSilently()` with a localhost alias.

License

Notifications You must be signed in to change notification settings

imhaage/react-ts-auth0-starter

Repository files navigation

react-ts-auth0-starter

  • Vite + plugin vite-plugin-mkcert
  • React v18
  • Typescript
  • Auth0 : <Auth0Provider> + useAuth0() hook

Features

  • Login / Logout buttons
  • Get user custom metadata from Auth0 Management API (fetch API with access token from getAccessTokenSilently())
  • Protected routes with react-router v6
  • Works with browsers blocking 3rd party cookies (Safari, Brave) : useRefhesTokens props + refresh token rotation + automatic reuse detection + cache location -> localStorage

User consent and applications

vite-plugin-mkcert enables HTTPS on localhost. With a localhost alias (app.dev is set by default in vite.config.ts) consent can be skipped and getAccessTokenSilently() doesn't throw a Consent required error.

Allowed callback URLs must not include localhost

https://auth0.com/docs/get-started/applications/confidential-and-public-applications/user-consent-and-third-party-applications#revoke-consent

About

Vite + React/Typescript + Auth0, localhost with HTTPS (thanks to vite-plugin-mkcert), alllows auth0 `getAccessTokenSilently()` with a localhost alias.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published