TiloBox
Back to directory
PocketBase project preview

PocketBase

An open-source, real-time Go backend in a single executable file with embedded SQLite, auth, file storage, and admin UI.

LicenseMIT
GitHub stars60.8k
Last commit1 weeks ago
Tags6 topics
BackendFirebase AlternativeRealtimeSqliteBaasGolang
Overview

Why consider PocketBase?

PocketBase is an open-source Go backend providing an embedded SQLite database, real-time subscriptions, file management, and an admin dashboard in a single executable.

Guided learning

Learn PocketBase by building

Practical setup notes, real use cases, and copy-ready examples in one focused guide.

4 min read 6 sections
In this guide6 sections

Building with PocketBase: A Single-File Backend

PocketBase is an open-source backend written in Go that integrates an embedded SQLite database, real-time subscriptions, file management, and an administration dashboard into a single executable file. This architecture simplifies deployment and operations by removing the need for separate database servers and file storage infrastructure for many applications.

By providing built-in authentication, access control rules, and an intuitive administrative interface out of the box, PocketBase allows developers to focus on application logic. It provides a REST API and official SDKs for JavaScript and Dart, making it accessible from web, mobile, desktop, and CLI environments.

Deployment Approaches

PocketBase offers two distinct deployment models depending on your project requirements and familiarity with Go.

PocketBase can be used as a standalone application by downloading a precompiled executable, or it can be integrated into custom applications as a Go framework. When operating as a standalone application, developers can still write custom business logic. Users can extend the backend functionality with both Go and JavaScript, as the prebuilt executable includes a JavaScript VM plugin enabled by default.

To run the standalone version, download the executable for your platform, extract it, and start the server:

bash
1./pocketbase serve

When started, the application will automatically generate a pb_data directory to store your application data, users, and uploaded files. It also provisions a pb_migrations directory, tracking database schema changes. The local environment serves static assets from a pb_public folder on http://127.0.0.1:8090, exposes the superuser dashboard at http://127.0.0.1:8090/_/, and provides the core backend operations at http://127.0.0.1:8090/api/.

Developing Custom Applications as a Go Framework

When a project requires complex business logic or integration with existing Go codebases, PocketBase can function as a toolkit. This approach embeds the PocketBase core within a custom Go application while maintaining the benefit of compiling down to a single portable executable.

Setting Up the Go Project

To initialize a custom application, create a new directory and start by defining the application entry point. You must have Go 1.25 or later installed. Create a file named main.go and implement the setup:

go
1package main
2
3import (
4 "log"
5
6 "github.com/pocketbase/pocketbase"
7 "github.com/pocketbase/pocketbase/core"
8)
9
10func main() {
11 app := pocketbase.New()
12
13 app.OnServe().BindFunc(func(se *core.ServeEvent) error {
14 // registers new "GET /hello" route
15 se.Router.GET("/hello", func(re *core.RequestEvent) error {
16 return re.String(200, "Hello world!")
17 })
18
19 return se.Next()
20 })
21
22 if err := app.Start(); err != nil {
23 log.Fatal(err)
24 }
25}

This code initializes the core engine, attaches a custom route hook (/hello), and starts the server.

To download the required dependencies for the project, run:

bash
1go mod init myapp && go mod tidy

Running and Compiling the Framework

During development, you can start the application directly using the Go toolchain:

bash
1go run main.go serve

When it is time to deploy the application, you can compile it into a statically linked binary. Using the pure Go SQLite driver supported by PocketBase, this ensures that the application has no external C library dependencies on the target system. Compile the executable with:

bash
1CGO_ENABLED=0 go build

This command produces a single executable that encompasses the SQLite database engine, the PocketBase framework, and your custom routing logic.

Supported Build Targets

Because PocketBase uses a pure Go SQLite implementation, it can cross-compile to a wide variety of target architectures without requiring a C compiler. The supported compilation targets include common architectures such as linux amd64, linux arm64, windows amd64, darwin amd64, and darwin arm64, as well as more specialized targets like linux riscv64 and freebsd amd64. This portability makes PocketBase suitable for environments ranging from Raspberry Pi devices to enterprise cloud servers.

Integrating SDK Clients

Once the backend is operational, frontend integration is straightforward using the provided SDK clients. The JavaScript SDK supports browser environments, Node.js, and React Native applications. The Dart SDK provides support for Flutter and Dart applications across web, mobile, and desktop platforms. These clients handle authentication token management, real-time Server-Sent Events (SSE) subscriptions, and standardized error handling, ensuring a smooth connection to the backend API endpoints exposed by the framework.

Related tools

More options with a similar category or technology profile.

PocketBase FAQs

PocketBase is listed as a Databases tool on TiloBox. Review the overview, features, and official documentation on this page to decide whether it solves your specific workflow.

Start with the project's GitHub repository and official website for supported installation and deployment instructions. Test the setup with representative data or a small project before rolling it out more widely.

PocketBase is listed under the MIT license. Read the complete license text and the project's notices before using, modifying, or distributing the software.

Production readiness depends on your requirements. Review maintenance activity, security practices, documentation, backup and upgrade procedures, and compatibility with your stack; then validate it in a non-production environment.

PocketBase is listed as an alternative to Supabase. Compare the core workflow, deployment model, integrations, and licensing against your must-have requirements before switching.