0
Fork 0
mirror of https://github.com/TanStack/router.git synced 2026-11-16 19:38:07 +00:00
router/examples/react/authenticated-routes-firebase
github-actions[bot] 67d9e69d72 ci: changeset release
History 2026-03-22 09:30:34 +00:00
..
.devcontainer docs: add devcontainer.json to all e2e/examples (#6972) 2026-03-18 15:43:14 +01:00
.vscode chore(examples): add authenticated-routes example using firebase (#3669) 2025-03-06 20:38:47 +13:00
src chore: generate route-tree for all sandboxes 2026-03-14 23:28:51 +13:00
.env.example chore(examples): match env.example with config for authenticated-routes-firebase (#4079) 2025-05-05 03:38:25 +12:00
.gitignore chore(examples): add authenticated-routes example using firebase (#3669) 2025-03-06 20:38:47 +13:00
index.html chore(examples): add authenticated-routes example using firebase (#3669) 2025-03-06 20:38:47 +13:00
package.json ci: changeset release 2026-03-22 09:30:34 +00:00
README.md docs(examples): standardize the READMEs for the React examples (#6014) 2025-12-07 01:39:44 +13:00
tsconfig.json fix: full npm registry URLs, sync package versions (#6035) 2025-12-07 11:37:18 +11:00
vite.config.js docs: move to tailwind 4 w/ vite (#6168) 2025-12-21 04:13:49 +01:00

TanStack Router - Authenticated Routes with Firebase Example

An example demonstrating authentication with Firebase and protected routes.

Start a new project based on this example

To start a new project based on this example, run:

npx gitpick TanStack/router/tree/main/examples/react/authenticated-routes-firebase authenticated-routes-firebase

Firebase Setup

  1. Create a Firebase project

    1. By default, firebase will configure an accepted domain for localhost...update if necessary!
  2. Enable Authentication in the Firebase console

  3. Add GitHub as an authentication provider:

    • Go to Authentication > Sign-in method > GitHub
    • Enable GitHub authentication
    • You'll need to set up OAuth in your GitHub account:
      • Go to GitHub Developer Settings
      • Create a new OAuth app
      • Set the homepage URL to your local or production URL
      • Set the callback URL to: https://your-firebase-project-id.firebaseapp.com/__/auth/handler
      • Copy the Client ID and Client Secret
    • Return to Firebase console and paste the GitHub Client ID and Client Secret
    • Save the changes
  4. Create a web app in your Firebase project:

    • Go to Project Overview > Add app > Web
    • Register the app with a nickname
    • Copy the Firebase configuration object for later use

Setup .env.local

Copy the .env.example provided and configure with your firebase credentials:

VITE_FIREBASE_API_KEY=
VITE_FIREBASE_AUTH_DOMAIN=
VITE_FIREBASE_PROJECT_ID=
VITE_FIREBASE_STORAGE_BUCKET=
VITE_FIREBASE_MESSAGING_SENDER_ID=
VITE_FIREBASE_APP_ID=

Getting Started

Install dependencies:

pnpm install

Start the development server:

pnpm dev

Build

Build for production:

pnpm build

About This Example

This example demonstrates:

  • Firebase authentication integration
  • Protected routes with Firebase Auth
  • Route guards
  • Login/logout with Firebase
  • User session management
  • Public vs private routes