cra-template-typescript-firebase v1.0.0
Create React App TypeScript Firebase Starter Template
Make sure you ⭐️ this repository if you find it helpful or interesting :)
✨ Installation
npx create-react-app your-project-name --template typescript-firebaseOR
yarn create react-app your-project-name --template typescript-firebaseNOTE: This template is also available in JavaScript here.
⚙️ Usage
SetUp firebase
Go to your
Firebase ConsoleClick on
Add project.- Follow steps and create project.
Click on web icon.
- Register web app.
- You will get details for setting up
Firebase SDK.
Add the config details in your
.envfile (available in root of your project).
SetUp SignIn with google
In your project console, click on
AuthenticationandGet Started.In
Sign-in method, click onGoogle.Toggle
Enableand click onSave.
To create a new screen
Create a new component in
src/screens.In your
src/config/routes.ts.
{
path: "/your-route",
component: YourScreenComponentName,
name: "Screen Name For Reference",
protected: false, // if user needs to be authenticated to access this screen
}To Deploy on GitHub Pages
Add your domain (your-github-username.github.io) to the OAuth redirect domains list in the
Firebase console -> Auth section -> Sign in method tab.update the
homepagefield in yourpackage.jsonto the domain you are hosting on. (By default it is:http://your-github-username.github.io/your-repo-name)(Optional) Test production build locally: Update the
homepagefield to/and run:
npm i -g serve # install serve globally via npm
npm run build-and-serve- Deploy to GitHub Pages run:
npm run deploy✨ Featues
1. Routing
Routing setup using react-router-dom.
With easily implementable private routes (routes only authenticated users can use).
Easily add new screens.
2. Authentication
Authentication implemented implemented
SignIn with Google implemented using firebase and react-firebase-hooks.
3. Firebase Configured
Firebase configured with GoogleAuthProvider implemented.
4. Material UI
Login Screen UI built using @mui/material.
5. Deploy on Github Pages
Deploying on GitHub pages powered by gh-pages and spa-github-pages
🔧 File Structure
├── src
│ ├── components
│ │ ├── auth
│ │ | ├── AuthChecker.tsx
│ │ | ├── AuthContainer.tsx
│ │ | ├── Logout.tsx
│ │ ├── utils
│ │ | ├── Center.tsx
│ ├── config
│ │ ├── firebase.config.ts
│ │ ├── firebase.ts
│ │ ├── routes.ts
│ ├── screens
│ │ ├── Login.tsx
│ │ ├── Home.tsx📝 Authors
- Hussain Pettiwala (@pettiboy)
Special thanks to this well written blog and this repo by alexandr-g.