FirebaseReactAuthBoilerplate
A boilerplate react app with Firebase auth Google oauth2 provider
Install / Use
/learn @emergentbit/FirebaseReactAuthBoilerplateREADME
This project was bootstrapped with Create React App.
It is a typescript implementation created with:
create-react-app ts-auth-ex --scripts-version=react-scripts-ts
What is this project?
I got tired of the broken or convoluted methods I was reading about regarding how to manage Firebase authentication within a react app.
This is an opinionated implementation of a react app that demands a user be signed in before presenting a UI. It uses the Google OAuth2 provider but with very little effort you should be able to use any of the Firebase supported OAuth2 providers.
There is no logic in the app other than giving a treatment to the signin gate. This is an attempt to add the least amount of logic/code to support a signin gate.
Flow
- User arrives at the site (maybe even a deep path) - save this path to local storage
- The routes/Index tries to resolve the firebase user auth
- If no user auth then redirect for signin
- On redirect result process and let the onAuthStatusChanged pick up the user
- On user resolved redirect to original path based on stored path (then remove path from local storage)
React boilerplate README
Below you will find some information on how to perform common tasks.<br> You can find the most recent version of this guide here.
Table of Contents
- Updating to New Releases
- Sending Feedback
- Folder Structure
- Available Scripts
- Supported Language Features and Polyfills
- Syntax Highlighting in the Editor
- Displaying Lint Output in the Editor
- Debugging in the Editor
- Formatting Code Automatically
- Changing the Page
<title> - Installing a Dependency
- Importing a Component
- Code Splitting
- Adding a Stylesheet
- Post-Processing CSS
- Adding a CSS Preprocessor (Sass, Less etc.)
- Adding Images, Fonts, and Files
- Using the
publicFolder - Using Global Variables
- Adding Bootstrap
- Adding Flow
- Adding Custom Environment Variables
- Can I Use Decorators?
- Integrating with an API Backend
- Proxying API Requests in Development
- Using HTTPS in Development
- Generating Dynamic
<meta>Tags on the Server - Pre-Rendering into Static HTML Files
- Injecting Data from the Server into the Page
- Running Tests
- Developing Components in Isolation
- Making a Progressive Web App
- Analyzing the Bundle Size
- Deployment
- Advanced Configuration
- Troubleshooting
- Something Missing?
Updating to New Releases
Create React App is divided into two packages:
create-react-appis a global command-line utility that you use to create new projects.react-scriptsis a development dependency in the generated projects (including this one).
You almost never need to update create-react-app itself: it delegates all the setup to react-scripts.
When you run create-react-app, it always creates the project with the latest version of react-scripts so you’ll get all the new features and improvements in newly created apps automatically.
To update an existing project to a new version of react-scripts, open the changelog, find the version you’re currently on (check package.json in this folder if you’re not sure), and apply the migration instructions for the newer versions.
In most cases bumping the react-scripts version in package.json and running npm install in this folder should be enough, but it’s good to consult the changelog for potential breaking changes.
We commit to keeping the breaking changes minimal so you can upgrade react-scripts painlessly.
Sending Feedback
We are always open to your feedback.
Folder Structure
After creation, your project should look like this:
my-app/
README.md
node_modules/
package.json
public/
index.html
favicon.ico
src/
App.css
App.js
App.test.js
index.css
index.js
logo.svg
For the project to build, these files must exist with exact filenames:
public/index.htmlis the page template;src/index.jsis the JavaScript entry point.
You can delete or rename the other files.
You may create subdirectories inside src. For faster rebuilds, only files inside src are processed by Webpack.<br>
You need to put any JS and CSS files inside src, otherwise Webpack won’t see them.
Only files inside public can be used from public/index.html.<br>
Read instructions below for using assets from JavaScript and HTML.
You can, however, create more top-level directories.<br> They will not be included in the production build so you can use them for things like documentation.
Available Scripts
In the project directory, you can run:
npm start
Runs the app in the development mode.<br> Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.<br> You will also see any lint errors in the console.
npm test
Launches the test runner in the interactive watch mode.<br> See the section about running tests for more information.
npm run build
Builds the app for production to the build folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br> Your app is ready to be deployed!
See the section about deployment for more information.
npm run eject
Note: this is a one-way operation. Once you eject, you can’t go back!
If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build d
