Skip to content

umrashrf/postbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

314 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Home Page Screenshot

Node.js Express.js PostgreSQL Better-Auth Let's Encrypt

Postbase

Drop-in replacement for Firebase, production grade, open source, localhost first and self-hosted using Node.js, Express.js, BetterAuth and PostgreSQL (JSONB)

Firebase πŸ’” | Supabase πŸ’” | Postbase ❀️

Demo Preact app is included !

Features

Authentication Features

  • Sign Up βž•πŸ‘€
  • Sign In πŸ”‘
  • Sign in with Google/Facebook/Apple etc. βž•πŸ‘€
  • Forgot Password β“πŸ”
  • Reset Password β™»οΈπŸ”
  • Email Verification Email βœ‰οΈβœ”οΈ
  • Phone Verification Codes πŸ“±βœ”οΈ
  • Delete User πŸ‘€βŒ

Special thanks to @better-auth/better-auth

Database Features

  • NoSQL Document Storage πŸ—„οΈ
  • Collections πŸ“
  • Query functions πŸ”
  • CRUD Functions πŸ› οΈ
  • Security Rules πŸ›‘οΈ
  • Database Migrations πŸ›’οΈ β†’ πŸ›’οΈ

File Upload / Storage

  • File Upload (https) πŸ“„β¬†οΈ
  • File Serving (https) πŸ“„β¬‡οΈ
  • Security Rules πŸ›‘οΈ

Admin & System

  • Admin SDK πŸ‘‘πŸ—„οΈ
  • Nginx Config 🧱
  • Systemd Service βš™οΈ
  • Git Push Deployment β¬†οΈπŸ™

Disclaimer !!!

Brand new project launched 02 Nov 2025, this is boiler plate but working! Expect heavy changes coming every few hours until stable

Mostly all code is ChatGPT generated but manually tested by human.

Getting Started

To create a new project with Postbase, all you have to do is clone this repo.

git clone https://github.com/umrashrf/postbase.git

then start backend and frontend servers and modify as needed!

Both backend/ and frontend/ folders have their own README.md

Vision

Make a drop-in replacement library for Firebase (keep same naming convention). So users can switch between Firebase and Postbase as they please.

Docs

Getting Started

import { initializeApp } from "../lib/postbase/compat/firebase/app";
import { getFirestore } from "../lib/postbase/compat/firebase/firestore/lite";
import { getStorage } from "../lib/postbase/compat/firebase/storage";
import { getDatabase } from "../lib/postbase/compat/firebase/database";

const firebaseConfig = {
    baseUrl: import.meta.env.VITE_API_BASE,
};

const app = initializeApp(firebaseConfig);

export const db = getFirestore(app);
export const storage = getStorage(app);
export const rtdbClient = getDatabase(app);

Authentication (Firebase Like API)

Sign Up

import { getAuth, createUserWithEmailAndPassword } from "./auth";

const auth = getAuth();

const userCredential = await createUserWithEmailAndPassword(auth, 'email', 'password');

Sign In

import { getAuth, signInWithEmailAndPassword } from "./auth";

const auth = getAuth();

const userCredential = await signInWithEmailAndPassword(auth, 'email', 'password');

auth.onAuthStateChanged, auth.currentUser and auth.currentUser.getIdToken()

import { auth } from './auth';

auth.onAuthStateChanged(user => {
    // user
    auth.currentUser === user // true
});

const token = auth.currentUser.getIdToken();
// token for API authentication and rules engine

Tip: Add this link https://email.riamu.io to your Sign Up page for your users to get a free email address

Document Storage (Firestore Like API)

Collections, get/set/where/orderBy/limit/delete

import { db } from "./postbase";

const data = await db.collection('users').doc('docId').get();
// getDoc(collection(db, 'users'), 'docId')

await db.collection('users').set({ name: "Umair" }, { merge: true });
// getDoc(collection(db, 'users'), 'docId')

const reference = db.collection('users')
    .where('name', '==', 'Umair')
    .orderBy('createdAt')
    .limit(5);
// const reference = getDocs(query(collection(db, 'users'), where('name', '==', 'Umair'), orderBy('createdAt')))

const docs = await reference.get();
// const docs = await getDocs(reference);

reference.onSnapshot(docs => {
    // use docs
});
// onSnapshot(reference, docs => {
// 
// })

Admin Client

import { createAdminClient } from './lib/postbase/compat/admin.js';
import { authClient } from './admin/auth.js';

const admin = createAdminClient({ authClient });

const user = await admin.auth().getUser(userId);

const doc = await admin.firestore().collection('collection').doc('docId').get();

Todo

  • Firebase Functions Replacement (Backend API can be used for now)

Important functions to replicate:

# https://firebase.google.com/docs/functions/schedule-functions
const { onSchedule } = require("firebase-functions/scheduler");

# https://firebase.google.com/docs/functions/callable
const { onCall } = require("firebase-functions/https");

# https://firebase.google.com/docs/functions/get-started
const { onRequest } = require("firebase-functions/https");
  • Firebase Storage Replacement (Support S3 and other backend)

In Progress

  • Testing

Done

  • Firebase Authentication Replacement
  • Firebase Firestore Replacement
  • Firebase Storage Replacement (Filebased Only)
  • Firebase Storage Replacement (HTTPS Based Upload)

License

MIT

About

Drop-in replacement for Firebase, production grade, open source, localhost first and self-hosted using Node.js, Express.js, BetterAuth and PostgreSQL (JSONB) - Firebase πŸ’” | Supabase πŸ’” | Postbase ❀️

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages