Skip to content

Open source, localhost supported, drop-in replacement and self-hosted alternative for Firebase using Node.js, Express.js, BetterAuth and PostgreSQL (JSONB) - Firebase πŸ’” | Supabase πŸ’” | Postbase ❀️ Special thanks to ChatGPT for providing the logo and helping me speed up coding.

License

Notifications You must be signed in to change notification settings

umrashrf/postbase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Postbase Logo

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

🐘 Postbase (Demo)

Open Source, localhost supported, Drop-in Replacement and Self-Hosted Alternative for Firebase using Node.js, Express.js, BetterAuth and PostgreSQL (JSONB), node-pg-migrate

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

Demo Preact app is included !

Features

Authentication Features

  • Sign Up βž•πŸ‘€
  • Sign In πŸ”‘
  • 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 Config βš™οΈ
  • 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

Docs

Authentication (Firebase Like API)

Sign Up

import { signIn } from './auth';

await signUp.email({ 
    email: '[email protected]', 
    password: 'secure-password', 
    name: 'Umair Ashraf', 
    callbackURL: "/dashboard",
});

Sign In

import { signIn } from './auth';

await signIn.email({ 
    email: '[email protected]',
    password: 'secure-password',
    callbackURL: '/dashboard',
});

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

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();

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

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

const docs = await reference.get();

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

Admin Client

import { createAdminClient } from './lib/postbase/compat/admin.js';
import { authClient } from './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

Open source, localhost supported, drop-in replacement and self-hosted alternative for Firebase using Node.js, Express.js, BetterAuth and PostgreSQL (JSONB) - Firebase πŸ’” | Supabase πŸ’” | Postbase ❀️ Special thanks to ChatGPT for providing the logo and helping me speed up coding.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages