Firebase Hosting — SPA Client

Real separate deployment

A public Auth0 client (Authorization Code + PKCE) using @auth0/auth0-spa-js · deployed as plain static files to classic Firebase Hosting, no build step, no server-side code at all · the only client in this suite with no server-held session of any kind

Try it on the real deployment

This runs on its own Firebase Hosting site with its own Auth0 application — log in there for real, view the decoded ID token claims and access token on the page itself, then log out.

Open the Firebase Hosting SPA demo
Two axes change at once: client type and hosting platform
Traditional/BFFHono siblingsFirebase Hosting SPA
Client typeConfidential (client secret)Confidential (client secret)Public (PKCE, no secret)
Where tokens liveServer — Firestore / encrypted cookieServer — encrypted cookie (Hono siblings)Browser memory only, never persisted
HostingVercel Functions (Node.js)Cloudflare Workers / Deno DeployFirebase Hosting — static files, zero server code
SDK@auth0/nextjs-auth0@auth0/auth0-hono@auth0/auth0-spa-js
On reloadSession cookie still valid — no re-auth neededSession cookie still valid — no re-auth neededMemory cache wiped — silent iframe re-auth attempt, or re-login
RevocationDelete session record / Back-Channel LogoutKey rotation or TTL (no server record by default)No session record ever existed — only the refresh token to revoke

The Hono siblings vary the hosting platform while keeping the same confidential-client shape as Traditional/BFF. This demo varies the client type itself — public instead of confidential — and happens to also land on a third hosting platform that, unlike the others, never runs any application code at all: Firebase Hosting serves the same static HTML and JS file to every request, with no routing, no middleware, and no backend to compromise.

Architecture & Token Flow

Traditional / BFF / Hono siblings (this suite)

Browser

Session cookie only — no tokens client-side

Server (Node.js / Workers / Deno)

Confidential client, holds tokens

Both

Auth0

Authorization Code + PKCE

Firebase Hosting SPA (this demo)

Browser

Public client, tokens held in memory

Firebase Hosting

Static files only — no server-side code at all

1Browser redirects to Auth0 Universal Login — identical PKCE flow to every other demo in this suite.
2Auth0 redirects back to the static page's own origin with an authorization code — there's no server-side callback route to receive it, so the page's own script checks window.location.search on every load.
3The SDK exchanges the code for tokens entirely in the browser and holds them in memory (cacheLocation: 'memory') — no server ever sees them, and Firebase Hosting never executes any code; it only ever serves the same static HTML/JS file.
4A page reload wipes the in-memory cache. getTokenSilently() then tries a hidden-iframe round trip against Auth0's own SSO cookie — if that's blocked (third-party cookie restrictions) or there's no session, the user sees the logged-out view, not a redirect loop.
5Revocation here means something different again: there's no cookie and no server-side session record. Killing access means expiring the refresh token server-side (Auth0 dashboard/Management API) or waiting out the access token's own short lifetime — the fastest revocation path of any demo in this suite, and the one with the least standing state to revoke in the first place.
Security Implications

Strengths

  • Genuinely zero server-side session anywhere in this demo — Firebase Hosting serves the same static HTML/JS file to every request and never executes any application code, which is a narrower attack surface than any confidential-client server in this suite (nothing to compromise server-side, because there is no server-side).
  • Firebase Hosting serves over HTTPS with a CDN by default — no separate TLS setup, same baseline every static host in this suite gets for free.
  • cacheLocation: 'memory' means tokens never touch localStorage or any persistent browser storage — closing the tab clears them completely, with no cleanup step required.

Risks & Considerations

  • The redirect URI allowlist — not client ID secrecy — is this client type's actual security boundary. The client ID is public by design, not a leaked secret; a third party can reuse it in their own authorization requests, but cannot register a second application under it. Exact-match callback/logout/origin URLs, not wildcards, are what actually stops a malicious page from completing a login flow and receiving the resulting code.
  • Memory-only token storage prevents theft at rest, but not active exfiltration: an attacker with script execution in this page's own origin (XSS) doesn't need to read any storage at all — they can simply call the already-running SDK's getTokenSilently() directly from the compromised page and get a live token handed to them.
  • A page reload wipes the in-memory cache, so getTokenSilently() depends on a hidden-iframe round trip against Auth0's own SSO session cookie to avoid a full interactive re-login on every refresh — browsers that restrict third-party cookies in that context (increasingly the default) can silently degrade this demo to "re-login on every reload" with no error visible to the user beyond that.
  • Refresh Token Rotation had to be explicitly enabled on this Auth0 application — setting useRefreshTokens: true in the SDK config alone is not sufficient for a public client; without the dashboard/API-side setting, the refresh exchange can fail without an obvious client-side signal pointing at the real cause.

Hardening Checklist

  • A real, tested Content-Security-Policy, not a placeholder — explicit connect-src for the Auth0 domain's token/userinfo endpoints, script-src scoped to wherever the SDK is actually loaded from (the CDN origin here), frame-src the Auth0 domain for the silent-auth iframe, plus baseline object-src 'none' / base-uri 'none' — verified to still allow login, callback, token renewal, and logout to all succeed without relaxing to wildcards or unsafe-inline.
  • Exact-match redirect URI allowlist on the Auth0 application, no wildcards — this is the client type's real security boundary, not the (public, non-secret) client ID.
  • Configure a real API audience so the displayed access token is a genuine decodable JWT rather than an opaque token meant only for /userinfo — otherwise a demo risks teaching the wrong mental model about what access tokens look like.
  • DPoP sender-constraining (already demoed elsewhere in this suite, /demo/spa) is a natural follow-up hardening step for a real deployment of this exact pattern — a stolen access token from an XSS-compromised page becomes far less useful if it's bound to a private key the attacker's script would also need to exfiltrate.