Skip to content

lafayettegabe/simple-firebase-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Warp

πŸ”₯ Simple Firebase REST API

Firebase & Next.js | Blazing-fast and serverless REST API

nextjs react redux firebase

Powered by Vercel

Why?

I created this demo app to showcase in my Operating Systems class for reading, adding, and deleting items from Firestore with just a few clicks. It also serves as a simple Next.js starter project integrated with Firebase Firestore, making replication easy.

The reason behind this project was the need to receive data from a microcontroller using FreeRTOS and store this data in a database for further analysis and potential integration into other applications.

Using this code

Remember to update the configuration in /lib/firebase.ts (the current one will only work for a few more days).

import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore";

// ============================================================
// ============================================================
// ========= Put your own Firebase configuration here =========
// πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡

const firebaseConfig = {
  apiKey: "AIzaSyCxqCyglAG9tUQlp8hxqpQFlJLKnog0h-w",
  authDomain: "os-example-313ee.firebaseapp.com",
  projectId: "os-example-313ee",
  storageBucket: "os-example-313ee.appspot.com",
  messagingSenderId: "754955767049",
  appId: "1:754955767049:web:f03b3eadd402e31a9fd7d8",
  measurementId: "G-SRV4Y5K1XE",
};

// ☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️☝️
// ============================================================
// ============================================================

const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
export const db = getFirestore(app);

Sample curl to test with external data:

curl -X POST http://localhost:3000/api/firebase \
-H "Content-Type: application/json" \
-d '{"data": {"lat": -37.82, "lon": 144.98}}'

Learn More about Next.js

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out Next.js deployment documentation for more details.