React Starter Kit for Firebase is a popular project template (aka, boilerplate) for building modern, scalable web applications with React, Relay, and GraphQL using serverless infrastructure provided by Google Cloud (Cloud SQL, Cloud Functions, CDN hosting, and file storage). It allows you to save time and build upon a solid foundation and design patterns.
- Create React App (★ 70k) for development and test infrastructure (see user guide)
- Material UI (★ 50k) to reduce development time by integrating Google's Material Design
- Passport.js (★ 15k) for authentication configured with stateless JWT tokens for sessions
- GraphQL.js (★ 15k) and Relay (★ 11k) for declarative data fetching and efficient client stage management
- Universal Router (★ 1k) + history (★ 3k) for declarative routing and client-side navigation optimized for Relay
- PostgreSQL database pre-configured with a query builder and migrations using Knex.js (★ 10k)
- Google Cloud & Firebase for serverless architecture - Cloud SQL, Cloud Functions, CDN hosting, file storage (docs)
- Node.js v10.15 or higher + Yarn v1.17 or higher (HINT: On Mac install them via Brew)
- Watchman file watcher used by Relay Modern
- PostgreSQL v9.6 or newer, only if you're planning to use a local db for development
Just clone the repo, update environment variables in
.env.local file, and start
$ git clone https://github.com/kriasoft/react-firebase-starter.git MyApp $ cd MyApp $ yarn setup # Installs dependencies; creates PostgreSQL database $ yarn start # Compile the app and opens it in a browser with "live reload"
Then open http://localhost:3000/ to see your app.
In order to re-compile GraphQL fragments, run
yarn relay or
yarn relay --watch (in watch mode).
How to Migrate Database Schema
$ yarn db-change # Create a new database migration file $ yarn db-migrate # Migrate database to the latest version $ yarn db-rollback # Rollback the latest migration $ yarn db-backup --env=prod # Write database backup to backup.sql $ yarn db-restore --env=dev # Restore database from backup.sql $ yarn db # Open PostgreSQL shell (for testing/debugging)
--env=test flags to any of the commands above will load the
corresponding database settings for the selected deployment environment from
Firebase Config API
How to Test
How to Deploy
$ yarn build # Build the in production mode (NODE_ENV=production) $ yarn deploy-test # Deploy the app to TEST environment $ yarn deploy-prod # Deploy the app to PROD environment
For more information refer to the Deployment guide in the project's Wiki.
How to Update
If you keep the original Git history after cloning this repo, you can always fetch and merge the recent updates back into your project by running:
$ git remote add rsk https://github.com/kriasoft/react-firebase-starter.git $ git checkout master $ git fetch rsk $ git merge rsk/master $ yarn install
NOTE: Try to merge as soon as the new changes land on the
master branch in the upstream
repository, otherwise your project may differ too much from the base/upstream repo.
Alternatively, you can use a folder diff tool like Beyond Compare for keeping your project
up to date with the base repository.
How to Contribute
Anyone and everyone is welcome to contribute to this project. The best way to start is by checking our open issues, submit a new issues or feature request, participate in discussions, upvote or downvote the issues you like or dislike, send pull requests.
Learn React.js and ES6
- React App SDK — Create React App modification that unlocks server-side rendering
- React Starter Kit — Boilerplate and tooling for building isomorphic web apps with React and Relay
- Node.js API Starter Kit — Boilerplate and tooling for building data APIs with Docker, Node.js and GraphQL
Copyright © 2015-present Kriasoft. This source code is licensed under the MIT license found in the LICENSE.txt file.