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.
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}}'
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
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.