Top Related Projects
The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
Build like a team of hundreds_
Parse Server for Node.js / Express
The flexible backend for all your projects π° Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
Blazing fast, instant realtime GraphQL APIs on all your data with fine grained access control, also trigger webhooks on database events.
Quick Overview
PocketBase is an open-source backend solution for building web and mobile applications. It combines a SQLite database, real-time subscriptions, authentication, and file storage into a single, lightweight executable. PocketBase is designed to be easy to set up and use, making it ideal for rapid prototyping and small to medium-sized projects.
Pros
- Easy setup and deployment with a single executable
- Built-in admin dashboard for managing data and users
- Real-time database with live subscriptions
- Automatic REST API generation for all collections
Cons
- Limited scalability due to SQLite backend
- Fewer advanced features compared to more established backend solutions
- Relatively new project, which may lead to potential stability issues
- Limited ecosystem and third-party integrations
Code Examples
- Initializing PocketBase client:
package main
import "github.com/pocketbase/pocketbase/sdk"
func main() {
client := sdk.NewClient("http://127.0.0.1:8090")
// Use the client to interact with PocketBase
}
- Creating a new record:
record := map[string]any{
"title": "My first post",
"content": "Hello, PocketBase!",
}
createdRecord, err := client.Collection("posts").Create(record)
if err != nil {
// Handle error
}
- Querying records:
resultList, err := client.Collection("posts").
Filter("created >= '2023-01-01'").
Sort("-created").
Limit(20).
All()
if err != nil {
// Handle error
}
- Real-time subscriptions:
client.Collection("posts").Subscribe("*", func(e *sdk.RealtimeEvent) {
switch e.Action {
case "create":
// Handle new post creation
case "update":
// Handle post update
case "delete":
// Handle post deletion
}
})
Getting Started
-
Download the PocketBase executable for your platform from the official website.
-
Run the executable:
./pocketbase serve
-
Access the admin UI at
http://127.0.0.1:8090/_/
to create collections and manage your data. -
Use the PocketBase Go SDK in your project:
import "github.com/pocketbase/pocketbase/sdk" client := sdk.NewClient("http://127.0.0.1:8090") // Start using PocketBase in your application
Competitor Comparisons
The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
Pros of Supabase
- More comprehensive feature set, including real-time subscriptions and storage
- Larger community and ecosystem, with more third-party integrations
- Offers a managed cloud service option for easier deployment
Cons of Supabase
- More complex setup and configuration compared to PocketBase
- Steeper learning curve due to its broader feature set
- Potentially higher resource requirements for self-hosting
Code Comparison
Supabase (JavaScript):
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('YOUR_SUPABASE_URL', 'YOUR_SUPABASE_KEY')
const { data, error } = await supabase
.from('users')
.select('*')
PocketBase (JavaScript):
import PocketBase from 'pocketbase'
const pb = new PocketBase('http://127.0.0.1:8090')
const records = await pb.collection('users').getList(1, 50)
Both examples demonstrate basic setup and a simple query, but Supabase's approach is more SQL-like, while PocketBase uses a more object-oriented style. Supabase requires separate URL and key parameters, whereas PocketBase only needs the server address.
Build like a team of hundreds_
Pros of Appwrite
- More comprehensive feature set, including authentication, database, storage, and serverless functions
- Larger community and ecosystem, with more integrations and third-party tools
- Supports multiple programming languages and platforms
Cons of Appwrite
- More complex setup and configuration compared to PocketBase
- Higher resource requirements due to its broader feature set
- Steeper learning curve for beginners
Code Comparison
PocketBase (Go):
package main
import "github.com/pocketbase/pocketbase"
func main() {
app := pocketbase.New()
app.Start()
}
Appwrite (PHP):
<?php
require_once 'vendor/autoload.php';
use Appwrite\Client;
use Appwrite\Services\Database;
$client = new Client();
$client->setEndpoint('https://[HOSTNAME_OR_IP]/v1')->setProject('5df5acd0d48c2');
$database = new Database($client);
Both PocketBase and Appwrite are open-source backend platforms, but they differ in scope and complexity. PocketBase is a lightweight, single-binary solution written in Go, focusing on simplicity and ease of use. Appwrite, on the other hand, is a more comprehensive platform with a wider range of features and language support. The choice between the two depends on project requirements, scalability needs, and developer preferences.
Parse Server for Node.js / Express
Pros of Parse Server
- More mature and battle-tested, with a larger community and ecosystem
- Offers more advanced features like cloud functions and live queries
- Supports multiple database backends (MongoDB, PostgreSQL)
Cons of Parse Server
- More complex setup and configuration process
- Requires separate database and file storage solutions
- Higher resource consumption and potentially slower performance
Code Comparison
Parse Server configuration:
const api = new ParseServer({
databaseURI: 'mongodb://localhost:27017/dev',
cloud: './cloud/main.js',
appId: 'myAppId',
masterKey: 'myMasterKey',
fileKey: 'optionalFileKey'
});
PocketBase configuration:
app := pocketbase.New()
if err := app.Start(); err != nil {
log.Fatal(err)
}
Parse Server and PocketBase are both open-source backend solutions, but they differ in their approach and target audience. Parse Server is a more feature-rich and flexible option, suitable for complex applications with specific requirements. It offers advanced features like cloud functions and live queries, making it powerful for experienced developers.
PocketBase, on the other hand, focuses on simplicity and ease of use. It provides a single executable with an embedded database, making it ideal for quick prototyping and smaller projects. PocketBase's setup is significantly simpler, requiring minimal configuration compared to Parse Server's more involved process.
While Parse Server supports multiple database backends, PocketBase uses its own embedded SQLite database, which simplifies deployment but may limit scalability for larger applications. Parse Server's flexibility comes at the cost of higher resource consumption and potentially slower performance, whereas PocketBase is designed to be lightweight and efficient.
The flexible backend for all your projects π° Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.
Pros of Directus
- More extensive and customizable admin panel with a rich set of features
- Supports multiple database types (MySQL, PostgreSQL, SQLite, etc.)
- Larger community and ecosystem with more extensions and integrations
Cons of Directus
- Heavier and more complex setup compared to PocketBase
- Requires more server resources and may have slower performance
- Steeper learning curve for developers new to the platform
Code Comparison
PocketBase (Go):
app := pocketbase.New()
app.OnRecordBeforeCreateRequest().Add(func(e *core.RecordCreateEvent) error {
e.Record.Set("created_at", time.Now())
return nil
})
Directus (JavaScript):
module.exports = function registerHook({ services, exceptions }) {
return {
'items.create': async function(input, { collection }) {
input.created_at = new Date();
return input;
}
};
};
Both examples show how to add a timestamp to a record before creation, demonstrating the different approaches and languages used in each project.
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
Pros of Strapi
- More extensive plugin ecosystem and customization options
- Larger community and wider adoption, leading to better support and resources
- Advanced content management features, including content versioning and localization
Cons of Strapi
- Higher resource requirements and potentially slower performance
- Steeper learning curve due to more complex architecture
- Less suitable for small-scale projects or rapid prototyping
Code Comparison
Strapi (JavaScript):
module.exports = {
async findOne(ctx) {
const { id } = ctx.params;
const entity = await strapi.services.restaurant.findOne({ id });
return sanitizeEntity(entity, { model: strapi.models.restaurant });
},
};
PocketBase (Go):
package main
import "github.com/pocketbase/pocketbase"
func main() {
app := pocketbase.New()
app.Start()
}
The code snippets demonstrate the different approaches and languages used by each project. Strapi uses JavaScript and provides more granular control over API endpoints, while PocketBase uses Go and offers a more streamlined setup process.
Blazing fast, instant realtime GraphQL APIs on all your data with fine grained access control, also trigger webhooks on database events.
Pros of GraphQL Engine
- More powerful and flexible GraphQL API generation
- Advanced authorization and access control features
- Better suited for complex, large-scale applications
Cons of GraphQL Engine
- Steeper learning curve and more complex setup
- Requires a separate database (PostgreSQL)
- Higher resource consumption and potential costs
Code Comparison
GraphQL Engine query example:
query {
users(where: {is_active: {_eq: true}}) {
id
name
email
}
}
PocketBase query example:
await pb.collection('users').getList(1, 50, {
filter: 'is_active = true'
});
Both PocketBase and GraphQL Engine offer powerful backend solutions, but they cater to different needs. PocketBase is a lightweight, all-in-one solution ideal for smaller projects and rapid prototyping. It provides a built-in database and admin UI, making it easy to get started quickly.
GraphQL Engine, on the other hand, is more suitable for complex, large-scale applications that require advanced querying capabilities and fine-grained access control. It offers a more robust GraphQL API generation and integrates well with existing PostgreSQL databases.
While PocketBase excels in simplicity and ease of use, GraphQL Engine provides more flexibility and scalability for demanding enterprise applications. The choice between the two depends on the specific requirements and scale of your project.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
PocketBase is an open source Go backend that includes:
- embedded database (SQLite) with realtime subscriptions
- built-in files and users management
- convenient Admin dashboard UI
- and simple REST-ish API
For documentation and examples, please visit https://pocketbase.io/docs.
[!WARNING] Please keep in mind that PocketBase is still under active development and therefore full backward compatibility is not guaranteed before reaching v1.0.0.
API SDK clients
The easiest way to interact with the PocketBase Web APIs is to use one of the official SDK clients:
- JavaScript - pocketbase/js-sdk (Browser, Node.js, React Native)
- Dart - pocketbase/dart-sdk (Web, Mobile, Desktop, CLI)
You could also check the recommendations in https://pocketbase.io/docs/how-to-use/.
Overview
Use as standalone app
You could download the prebuilt executable for your platform from the Releases page.
Once downloaded, extract the archive and run ./pocketbase serve
in the extracted directory.
The prebuilt executables are based on the examples/base/main.go
file and comes with the JS VM plugin enabled by default which allows to extend PocketBase with JavaScript (for more details please refer to Extend with JavaScript).
Use as a Go framework/toolkit
PocketBase is distributed as a regular Go library package which allows you to build your own custom app specific business logic and still have a single portable executable at the end.
Here is a minimal example:
-
Install Go 1.23+ (if you haven't already)
-
Create a new project directory with the following
main.go
file inside it:package main import ( "log" "github.com/pocketbase/pocketbase" "github.com/pocketbase/pocketbase/core" ) func main() { app := pocketbase.New() app.OnServe().BindFunc(func(se *core.ServeEvent) error { // registers new "GET /hello" route se.Router.GET("/hello", func(re *core.RequestEvent) error { return re.String(200, "Hello world!") }) return se.Next() }) if err := app.Start(); err != nil { log.Fatal(err) } }
-
To init the dependencies, run
go mod init myapp && go mod tidy
. -
To start the application, run
go run main.go serve
. -
To build a statically linked executable, you can run
CGO_ENABLED=0 go build
and then start the created executable with./myapp serve
.
For more details please refer to Extend with Go.
Building and running the repo main.go example
To build the minimal standalone executable, like the prebuilt ones in the releases page, you can simply run go build
inside the examples/base
directory:
- Install Go 1.23+ (if you haven't already)
- Clone/download the repo
- Navigate to
examples/base
- Run
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
(https://go.dev/doc/install/source#environment) - Start the created executable by running
./base serve
.
Note that the supported build targets by the pure Go SQLite driver at the moment are:
darwin amd64
darwin arm64
freebsd amd64
freebsd arm64
linux 386
linux amd64
linux arm
linux arm64
linux ppc64le
linux riscv64
linux s390x
windows amd64
windows arm64
Testing
PocketBase comes with mixed bag of unit and integration tests.
To run them, use the standard go test
command:
go test ./...
Check also the Testing guide to learn how to write your own custom application tests.
Security
If you discover a security vulnerability within PocketBase, please send an e-mail to support at pocketbase.io.
All reports will be promptly addressed and you'll be credited in the fix release notes.
Contributing
PocketBase is free and open source project licensed under the MIT License. You are free to do whatever you want with it, even offering it as a paid service.
You could help continuing its development by:
PRs for new OAuth2 providers, bug fixes, code optimizations and documentation improvements are more than welcome.
But please refrain creating PRs for new features without previously discussing the implementation details. PocketBase has a roadmap and I try to work on issues in specific order and such PRs often come in out of nowhere and skew all initial planning with tedious back-and-forth communication.
Don't get upset if I close your PR, even if it is well executed and tested. This doesn't mean that it will never be merged. Later we can always refer to it and/or take pieces of your implementation when the time comes to work on the issue (don't worry you'll be credited in the release notes).
Top Related Projects
The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
Build like a team of hundreds_
Parse Server for Node.js / Express
The flexible backend for all your projects π° Turn your DB into a headless CMS, admin panels, or apps with a custom UI, instant APIs, auth & more.
π Strapi is the leading open-source headless CMS. Itβs 100% JavaScript/TypeScript, fully customizable, and developer-first.
Blazing fast, instant realtime GraphQL APIs on all your data with fine grained access control, also trigger webhooks on database events.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot