Skip to content

marcomelilli/gatsby-firebase-simple-auth

Repository files navigation

Logo

Gatsby Firebase Authentication Starter

This is a gatsby starter to show how an authentication workflow is implemented in Gatsby using Firebase as authentication provider.

This starter follows the best practices described in the official gatsby site:

It uses Gatsby Plugin Create Client Path to set private routes.

How it works in short:

  • Gatsby renders all unauthenticated routes as usual static pages.
  • Authenticated routes are whitelisted as client-only (in this starter all dynamic pages are under the path 'mysite.com/app/*').
  • Logged-out users are redirected to the login page if they attempt to visit private routes.
  • Logged-in users will see their private content.

Getting started with Firebase

Copy and rename .env.sample to .env.development and .env.production in your root directory. Use these environment variables for Firebase:

FIREBASE_API_KEY=<YOUR_FIREBASE_API_KEY>
FIREBASE_AUTH_DOMAIN=<YOUR_FIREBASE_AUTH_DOMAIN>
FIREBASE_DATABASE_URL=<YOUR_FIREBASE_DATABASE_URL>
FIREBASE_PROJECT_ID=<YOUR_FIREBASE_PROJECT_ID>
FIREBASE_STORAGE_BUCKET=<YOUR_FIREBASE_STORAGE_BUCKET>
FIREBASE_MESSAGING_SENDER_ID=<YOUR_FIREBASE_MESSAGING_SENDER_ID>
FIREBASE_APP_ID=<YOUR_FIREBASE_APP_ID>

Start developing

npm install
gatsby develop 

Contributing

If you want to contribute to this starter, consider:

  • Reporting bugs and errors
  • Improve the documentation
  • Creating new features and pull requests

All contributions are welcome!

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •