Introduction

PostgresBase is a modified version of PocketBase that replaces the default SQLite database with PostgreSQL or MySQL.

This project was born out of the need to run PocketBase in highly available, clustered, or high-concurrency environments where SQLite's file-locking mechanism might become a bottleneck.

Installation

Download the binary for your platform and run it using a standard DSN string.

PostgreSQL

./pb serve --dataDsn "postgres://user:pass@localhost:5432/dbname?sslmode=disable"

MySQL

./pb serve --dataDsn "mysql://user:pass@tcp(localhost:3306)/dbname"

Redis Caching

You can enable enterprise-grade caching by providing a Redis DSN:

./pb serve --redisDsn "redis://localhost:6379/0"

Once connected, you can toggle caching for individual collections in the Cache tab of the collection settings.

Projects

Managing hundreds of tables? Use the Projects feature to group related collections together. This keeps your sidebar organized and focuses your development workflow.

High Availability (HA)

PostgresBase is designed for clustered environments. To deploy in HA mode:

# Example HA Node Start
./pb serve --dataDsn "postgres://lb-address:5432/db" --redisDsn "redis://redis-cluster:6379/0"

System Functions

Authentication

Built-in Auth with support for Email/Password, OAuth2 (Google, GitHub, etc.), and custom tokens.

Database & API

Instant RESTful API for your collections with powerful filtering, sorting, and expanded relations.

Realtime

Subscribe to record changes in realtime using Server-Sent Events (SSE).

File Storage

Seamless file uploads to local storage or S3-compatible providers.

JS-SDK Tutorial

Integration with PostgresBase is easy using the official-compatible JS-SDK.

1. Initialization

import PocketBase from 'pocketbase';

const pb = new PocketBase('http://127.0.0.1:8090');

2. Authentication

const authData = await pb.collection('users').authWithPassword('test@example.com', '1234567890');

3. CRUD Operations

// List records
const records = await pb.collection('posts').getList(1, 50, { filter: 'created > "2022-01-01"' });

// Create record
const record = await pb.collection('posts').create({ title: 'Hello World' });

4. Realtime Subscription

pb.collection('posts').subscribe('*', function (e) {
    console.log(e.action);
    console.log(e.record);
});