Git Product home page Git Product logo

ovidiumihaibelciug / gatsby-firebase-starter Goto Github PK

View Code? Open in Web Editor NEW
59.0 4.0 17.0 4.48 MB

πŸ”₯ Starter Project / Boilerplate for Authentication and creating Dynamic pages from collections with Firebase and Gatsby.js.

Home Page: https://gatsby-firebase-starter.netlify.com/

License: MIT License

JavaScript 65.74% CSS 34.26%
gatsby firebase firestore react firestore-database firebase-auth authentication reactjs

gatsby-firebase-starter's Introduction

Gatsby

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

  1. 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
  2. Add firebase config

    Log in to firebase console and replace the config from firebaseConfig.js with your settings.

  3. Start developing.

    Navigate into your new site’s directory and start it up.

    cd my-firebase-starter/
    gatsby develop
  4. 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.

  5. Make dynamic pages

    Open templates.js and add your dynamic pages like this:

    [
      {
        path: '/post',
        collection: 'posts',
        param: 'title',
        context: ['title', 'description'],
        fileName: 'post',
      },
    ];
    1. path is the url of the page, for example test.com/post

    2. collection is the name of the collection from firestore, at build time this starter will retrieve and make pages with all the documents from this collection

    3. param the parameter from url, the equivalent of /post/:param in React Router

    4. context the fields from the collection that will be requested at build time, then you can access the data from this.props.pageContext. For example for this context: ['title', 'description'], you'll be able to get the data from here:

    const {
      pageContext: { title, description },
    } = this.props;
    1. filename the name of the file from templates folder 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
  1. /node_modules: This directory contains all of the modules of code that your project depends on (npm packages) are automatically installed.

  2. /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. src is a convention for β€œsource code”.

  3. /components: This folder contains the React components structured following the Atomic Design methodology

    3.1. atoms Atoms are the smallest possible components, such as buttons, titles, inputs.

    3.2 molecules They 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 scenes This is a combination of templates and organisms. Basically these are the components that will be used directly in /pages

  1. constants: Some constants use throughout the app.

  2. pages: Components under src/pages become pages automatically with paths based on their file name.

  3. styles: The styles of the app. (Made with scss)

  4. utils: Firebase setup, Auth setup and reusable code used throughout the app.

πŸ’« Deploy

Deploy to Netlify

πŸŽ“ 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.

gatsby-firebase-starter's People

Contributors

dandv avatar itwasmattgregg avatar kg609 avatar ovidiumihaibelciug avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gatsby-firebase-starter's Issues

Users is not registered if signed up via email

Hi -

This is a great starter project! I was playing around with it and noticed that a user is not registered in firestore if you sign up through email but it does at least work if you sign up through Google. This is true even after confirming the email. Is this intentional?

Thanks!

wrong implementation of auth.onAuthStateChanged in firebase.js

Hi,
I am using your code to build my website and it is very useful.
Inside the Firebase class a method is not optimized to me. This is onAuthUserListener which is called every single page navigation

The problem is that the listener onAuthUserListener returns every time is called, even if the user status does not change.
This in turn cause the user.get() method ask data from the server

get() attempts to provide up-to-date data when possible by waiting for data from the server

this results in unnecessary high number of document reads, consuming the provider traffic

[Build] Posts

Posts are not built properly after deploy. Basically the html doesn't show when you see view page source.

License

Hi, thanks so much for creating this πŸ”₯template! Unfortunately, since your project does not have a license, it's not clear whether I have your permission to fork, clone, build, or use the code.

Could you please add a license file to clarify your position on this? I don't want to assume that you're making this project for open source, but I am interested in using it for some of my projects. I'll probably contribute some upstream if your intentions are to make this OSS.

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.