🛠️ Redirect.jsx

@components/react/auth/Redirect.jsx

Redirect Component

This component handles the redirect step after a user signs in with an OAuth provider (e.g. Google/Supabase). It is used on pages/signin.astro, extracts login tokens from the URL, calls your server to create a secure session cookie, and then redirects the user to their dashboard (or another page). It works in conjunction with pages/api/auth/set-session.ts - set-session.ts dictates where each user type is redirected after login


How it works

  1. Page loads → the component checks the URL for #access_token and #refresh_token.
  2. If tokens exist → it sends them to your API route (/api/auth/set-session).
  3. The server sets a cookie → meaning the browser is now securely signed in.
  4. If successful → the user is redirected to /dashboard (or another page returned by the server).
  5. If failed → an error message is shown.

When to use

  • Place this component on the page your OAuth provider redirects back to.
  • Example: if Google login sends the user to /auth/callback, add this component there.
  • It will automatically handle sign-in and send the user to the right place.


Free shipping over £60.00

Delivered with care. No code needed.