PocketBase is an entire backend in a single file. One binary gives you a database, REST API, real-time subscriptions, auth, file storage, and an admin dashboard. Under 15MB.
What Makes PocketBase Special?
- Single file — one binary, that's your entire backend
- Real-time — SSE subscriptions out of the box
- Auth built-in — email/password + OAuth2 providers
- File storage — upload and serve files with S3 support
- Admin UI — beautiful dashboard included
The Hidden API: Real-Time Subscriptions
import PocketBase from 'pocketbase';
const pb = new PocketBase('http://127.0.0.1:8090');
// Auth
await pb.collection('users').authWithPassword('user@example.com', 'password');
// CRUD operations
const posts = await pb.collection('posts').getList(1, 20, {
filter: 'published = true',
sort: '-created',
expand: 'author,tags'
});
// Create
const newPost = await pb.collection('posts').create({
title: 'My Post',
content: 'Hello World',
author: pb.authStore.model.id,
published: true
});
// Real-time subscriptions — auto-updates!
pb.collection('messages').subscribe('*', function (e) {
console.log(e.action); // 'create', 'update', 'delete'
console.log(e.record);
updateUI(e.record);
});
// Subscribe to specific record
pb.collection('posts').subscribe('RECORD_ID', function (e) {
console.log('Post updated:', e.record);
});
File Upload API
// Upload files
const formData = new FormData();
formData.append('title', 'My Photo');
formData.append('image', fileInput.files[0]);
const record = await pb.collection('photos').create(formData);
// Get file URL
const url = pb.files.getUrl(record, record.image);
// With thumbnail
const thumb = pb.files.getUrl(record, record.image, { thumb: '100x100' });
Custom API Routes (Hooks)
// pb_hooks/main.pb.js
routeAdd('GET', '/api/stats', (e) => {
const totalUsers = $app.dao().findRecordsByFilter('users', '', '', 0, 0).length;
const totalPosts = $app.dao().findRecordsByFilter('posts', 'published = true', '', 0, 0).length;
return e.json(200, { users: totalUsers, posts: totalPosts });
});
// Hooks — run code on CRUD events
onRecordAfterCreateRequest((e) => {
if (e.collection.name === 'orders') {
// Send notification
$app.dao().sendEmail(e.record.get('email'), 'Order confirmed', '...');
}
}, 'orders');
Quick Start
# Download single binary
wget https://github.com/pocketbase/pocketbase/releases/latest/download/pocketbase_linux_amd64.zip
unzip pocketbase_linux_amd64.zip
./pocketbase serve
# Admin: localhost:8090/_/
# API: localhost:8090/api/
Why Solo Developers Choose PocketBase
A solo developer shared: "I built and launched a SaaS in a weekend. PocketBase is the backend — auth, database, file storage, real-time, all in one 15MB binary. My hosting costs $5/month on a VPS. The entire stack is one file I can backup with cp."
Building MVPs fast? Email spinov001@gmail.com or check my developer tools.
PocketBase vs Supabase vs Firebase — what's your backend choice?
Top comments (0)