Summary: this repository contains complete integration of Firebase Cloud Messaging and the web client using Next.js
- Firebase Account
- Node.js v18+
- Some fundamentals knowledge of NestJS and Next.js
- pnpm or any desired package management
- Go to Firebase Console.
- Add a new project or select existing project
- On the top left navigation menu, click the cog button then click the "Project settings" link.
- On the project settings page, navigate the tab control to "Service accounts".
- Click the "Generate new private key" button.
- The dialog will show and save the file. We will use some of these keys later.
After finished setup Firebase project and get private key file. We will select those keys and inject to our environment file.
- Open the recently loaded private key file.
- Go to the
apps/backend
folder. - Copy the
.env.example
to.env
- Replacing these keys:
You can print the key from the json using the
FIREBASE_CLIENT_EMAIL=<YOUR_CLIENT_EMAIL> FIREBASE_PRIVATE_KEY=<YOUR_PRIVATE_KEY> FIREBASE_PROJECT_ID=<YOUR_FIREBASE_PROJECT>
jq
command$ cat <your_firebase_private_key_file>.json | jq '{project_id, private_key, client_email}' { "project_id": "<YOUR_PROJECT_ID>", "private_key": "<YOUR_PRIVATE_KEY>", "client_email": "<YOUR_CLIENT_EMAIL>" }
- Save the file and restart the api server via:
$ pnpm --filter api run start:dev # or $ cd apps/api $ pnpm run start:dev
- The API will start without any error.