gatsby-firebase-starter
gatsby-firebase-starter copied to clipboard
π₯ Starter Project / Boilerplate for Authentication and creating Dynamic pages from collections with Firebase and Gatsby.js.
Gatsby Firebase starter
Kick off your project with this gatsby firebase boilerplate. This starter ships with the main Gatsby configuration files you might need to get up and running blazing fast with the blazing fast app generator for React.
π Quick start
-
Create a Gatsby site.
Use the Gatsby CLI to create a new site, specifying the blog starter.
# create a new Gatsby site using the blog starter gatsby new my-firebase-starter ovidiumihaibelciug/gatsby-firebase-starter -
Add firebase config
Log in to firebase console and replace the config from
firebaseConfig.jswith your settings. -
Start developing.
Navigate into your new siteβs directory and start it up.
cd my-firebase-starter/ gatsby develop -
Open the source code and start editing!
Your site is now running at
http://localhost:8000!Note: You'll also see a second link:
http://localhost:8000/___graphql. This is a tool you can use to experiment with querying your data. Learn more about using this tool in the Gatsby tutorial. -
Make dynamic pages
Open
templates.jsand add your dynamic pages like this:[ { path: '/post', collection: 'posts', param: 'title', context: ['title', 'description'], fileName: 'post', }, ];-
pathis the url of the page, for exampletest.com/post -
collectionis the name of the collection from firestore, at build time this starter will retrieve and make pages with all the documents from this collection -
paramthe parameter from url, the equivalent of/post/:paraminReact Router -
contextthe fields from the collection that will be requested atbuildtime, then you can access the data fromthis.props.pageContext. For example for thiscontext: ['title', 'description'],you'll be able to get the data from here:
const { pageContext: { title, description }, } = this.props;filenamethe name of the file fromtemplatesfolder that you'll use to render the data from that collection
-
βοΈ Features
- Dynamic pages from Firestore collections
- Includes React Helmet to allow editing site meta tags
- PWA Support
- SEO
- Sign In
- Sign Up
- Sign Out
- Password Forget
- Password Change
- Verification Email
- Protected Routes with Authorization
- Social Logins with Google, Facebook and Twitter
- Linking of Social Logins on Account dashboard
- Auth Persistence with Local Storage
- Database with Users and Posts
π§ What's inside?
A quick look at the folder structure.
βββ node_modules
βββ src
βββ assets
βββ components
βββ atoms
βββ molecules
βββ scenes
βββ constants
βββ pages
βββ styles
βββ templates
βββ utils
-
/node_modules: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed. -
/src: This directory will contain all of the code related to what you will see on the front-end of your site (what you see in the browser) such as your site header or a page template.srcis a convention for βsource codeβ. -
/components: This folder contains the React components structured following the Atomic Design methodology3.1.
atomsAtoms are the smallest possible components, such as buttons, titles, inputs.3.2
moleculesThey are the composition of one or more components of atoms. Here we begin to compose complex components and reuse some of those components.3.3
scenesThis is a combination of templates and organisms. Basically these are the components that will be used directly in/pages
-
constants: Some constants use throughout the app. -
pages: Components under src/pages become pages automatically with paths based on their file name. -
styles: The styles of the app. (Made with scss) -
utils: Firebase setup, Auth setup and reusable code used throughout the app.
π« Deploy
π Learning Gatsby
Looking for more guidance? Full documentation for Gatsby lives on the website. Here are some places to start:
-
For most developers, we recommend starting with our in-depth tutorial for creating a site with Gatsby. It starts with zero assumptions about your level of ability and walks through every step of the process.
-
To dive straight into code samples, head to our documentation. In particular, check out the Guides, API Reference, and Advanced Tutorials sections in the sidebar.