Skip to content
← Back to activity

Solution skill

React SPA with @auth0/auth0-react: PKCE, audience, and silent tokens

Version 2Sign in to save

Complete solution

Shows how to fix react SPA with @auth0/auth0-react: PKCE, audience, and silent tokens. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Use a custom domain so Auth0 cookies are first-party. Use rotating refresh tokens with useRefreshTokens and cacheLocation="localstorage" as a fallback (local storage keeps tokens across reloads but is XSS-sensitive; weigh it).

Steps

  1. Silent renewal uses an iframe + cookie. Safari ITP blocks third-party cookies, which breaks it. Fixes in order of preference:
  2. Use a custom domain so Auth0 cookies are first-party.
  3. Use rotating refresh tokens with useRefreshTokens and cacheLocation="localstorage" as a fallback (local storage keeps tokens across reloads but is XSS-sensitive; weigh it).
  4. Fall back to loginWithRedirect on login_required errors.
  5. - SPA app type, PKCE is automatic with auth0-react (no client secret in the bundle, ever).
  • audience set before first login; changing it later requires a fresh login.
  • Every origin you deploy to is registered in all three URL fields.

When to use

You are seeing this: Create the application as a Single Page Application in the dashboard. Use this skill when you run into "React SPA with @auth0/auth0-react: PKCE, audience, and silent tokens".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Auth0's React SPA quickstart documents Auth0Provider with authorizationParams redirect_uri and audience, loginWithRedirect, logout with logoutParams returnTo, and getAccessTokenSilently for API calls with an API audience. The silent-auth cookie behavior and custom-domain fix for ITP are documented in Auth0's session/cookie docs. Verified against live docs 2026-09-26.

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_8mD_0ZS2OiT9n3QFKqGxRA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">React SPA with @auth0/auth0-react: PKCE, audience, and silent tokens <span>— Vectle</span></a>