Code Monkey home page Code Monkey logo

react-spotify-firebase-boilerplate's Introduction

React / Spotify Authorization Code Flow / Firebase Boilerplate

A minimal way to get started and build a simple full-stack web app using create-react-app and Firebase.

Boilerplate project setup using:

  • Frontend: React w/ create-react-app, FCs and Hooks, Typescript
  • Backend: Firebase w/ Node.js Cloud Functions, Typescript
  • Auth: Includes implementation of Spotify Authorization API

Get Started

  • Clone this repo

Installation

  • Run npm install to install the packages declared in package.json

Firebase

  • Learn how to set up a firebase project here: Add Firebase to your Javascript project
    • Note that Step 3 is partially taken care of with the 'Using module bundlers' approach. See ./src/components/Firebase.
    • To initialize Firebase, Create a .env file and put your firebase config details there, as labelled in src/components/Firebase/firebase.ts (example being REACT_APP_API_KEY={your API key here}). .env is excluded in .gitignore
    • After changing environment variables, you need to restart your development server
  • After installing the firebase CLI, make sure to run firebase init to create a .firebaserc file, which points your Firebase CLI (deploying functions, firestore/storage rules, etc.) to the right project. Note this might rewrite the ./functions folder though. Learn more here: Firebase CLI reference

Spotify

  • Retrieve your app's Spotify client ID and secret from the Spotify Developer Dashboard. Use the firebase CLI to upload these to your config as expected in functions/src/Auth/config.ts
  • Modify the other values in functions/src/Auth/config.ts as appropriate
  • Miror those values in src/constants/auth.tsx. Spotify expects these values to be identical between API calls when exchanging the code for the access and refresh tokens.

Run

  • Run npm run start

Other Details

Frontend:

  • Firebase client SDK is implemented via a wrapper/gateway class in ./src/components/Firebase.
  • Convenient React Contexts and hooks set up to provide the Firebase client instance and current user Auth session throughout the React app (useFirebase() and useSession())
  • Uses react-router for routing
  • Uses react-boostrap

Other Resources

Questions?

  • Have questions? Please open an issue and I'll get back to you by EOD. These are highly welcome--then the readme can be updated to provide this information and be more clear.
  • PRs are welcome!
  • Good luck on building!

Thanks

Thanks to @ly-chen for guidance on setting up the Spotify auth flow.

react-spotify-firebase-boilerplate's People

Contributors

brianjychan avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-spotify-firebase-boilerplate's Issues

Uploading Spotify tokens

What would the terminal script look like for using the firebase cli to uploading your client id and secret. I'm not having such luck. Really great project!

Firebase Web9

Hello!

Thank you for the Web 8 boilerplate! It's been helpful to learn how to implement an oAuth2 authorization flow. By any chance do you plan on updating the repository to the new Firebase Web9 SDK?

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.