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 Firebase (Cloud SQL, Cloud Functions, CDN hosting, and file storage). It allows you to save time and build upon a solid foundation and design patterns.
View online demo (API, data model) | Follow us on Twitter | Get FREE support on Telegram | Visit our sponsors:
This project was bootstraped with React Starter Kit for Firebase by Kriasoft.
- Create React App (★ 46k) for development and test infrastructure (see user guide)
- Material UI (★ 35k) to reduce development time by integrating Google's Material Design
- Styled Components (★ 15k) for component friendly CSS styles with a great DX (docs)
- Passport.js (★ 13k) for authentication configured with stateless JWT tokens for sessions
- GraphQL.js (★ 10k) 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 (★ 6k)
- Firebase for serverless architecture - Cloud SQL, Cloud Functions, CDN hosting, and file storage (docs)
Also, you need to be familiar with HTML, CSS, JavaScript (ES2015) and React.
├── build/ # Compiled output
├── migrations/ # Database schema migration files
├── node_modules/ # 3rd-party libraries and utilities
├── public/ # Static files such as favicon.ico etc.
├── scripts/ # Automation scripts (yarn update-schema etc.)
├── seeds/ # Reference and seed data for the database
├── src/ # Application source code
│ ├── admin/ # Admin section (Dashboard, User Management etc.)
│ ├── components/ # Shared React components
│ ├── news/ # News section (example)
│ ├── pages/ # Static pages (landing, about, privacy, etc.)
│ ├── server/ # Server-side code (API, authentication, etc.)
│ │ ├── db/ # Database client
│ │ ├── story/ # Story related schema, queries, and mutations
│ │ ├── templates/ # HTML templates for server-side rendering
│ │ ├── user/ # User related schema, queries, and mutations
│ │ ├── api.js # GraphQL API middleware
│ │ ├── Context.js # GraphQL context wrapper
│ │ ├── createRelay.js # Relay factory method for Node.js environment
│ │ ├── login.js # Authentication middleware (e.g. /login/facebook)
│ │ ├── schema.js # GraphQL schema
│ │ └── ssr.js # Server-side rendering middleware
│ ├── user/ # User pages (login, account settings, user profile, etc)
│ ├── app.browser.js # Client-side rendering, e.g. ReactDOM.render(<App />, container)
│ ├── app.node.js # Server-side rendering, e.g. ReactDOMServer.renderToString(<App />)
│ ├── auth.js # Client-side authentication manager
│ ├── createRelay.js # Relay factory method for browser envrironment
│ ├── router.js # Universal application router
│ ├── graphql.schema # GraphQL schema (auto-generated, used by Relay)
│ ├── serviceWorker.js # Service worker helper methods
│ └── theme.js # Overrides for Material UI default styles
├── .env # Environment variables
├── config-overrides.js # Configuration overrides for Babel and Webpack
└── package.json # The list of project dependencies + NPM scripts
- Node.js v8.9 or higher + Yarn v1.3 or higher (HINT: On Mac install them via Brew)
- VS Code editor (preferred) + Project Snippets, EditorConfig, ESLint, Flow, Prettier, and Babel JavaScript plug-ins
- 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
and/or .env.local
file, and start
hacking:
$ 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.
$ 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-save # Save data from database to JSON files
$ yarn db-seed # Seed database with previously saved data
$ yarn lint # Check JavaScript and CSS code for potential issues
$ yarn lint-fix # Attempt to automatically fix ESLint warnings
$ yarn test # Run unit tests. Or, `yarn test -- --watch`
- Create a new Google Cloud project and Cloud SQL database.
- Open your Google Cloud project in Firebase dashboard and configure Facebook authentication.
- Update Firebase project IDs for production and development environments in
.firebaserc
file. - Save Firebase API key, authentication domain and GPC service key in Firebase Functions
environment. For example
firebase functions:config:set api.browserkey="..." auth.domain="..."
- Update database host/user/password in either
.env
or.env.local
file and migrate your Cloud SQL database schema to the latest version by runningyarn db-migrate
. - Finally, deploy your application by running:
$ yarn deploy # Build the app and deploy to development environment
$ yarn deploy-prod # Build the app and deploy to production
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 react-firebase-starter https://github.com/kriasoft/react-firebase-starter.git
git checkout master
git fetch react-firebase-starter
git merge react-firebase-starter/master
yarn install
yarn relay
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.
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.
🎓 React for Beginners and ES6 Training Course by Wes Bos
📗 React: Up & Running: Building Web Applications by Stoyan Stefanov (Aug, 2016)
📗 Getting Started with React by Doel Sengupta and Manu Singhal (Apr, 2016)
📗 You Don't Know JS: ES6 & Beyond by Kyle Simpson (Dec, 2015)
- 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.
Made with ♥ by Konstantin Tarkus (@koistya, blog) and contributors