PocketBase Review: The All-in-One Go Backend for Solo Developers

10月9日 Published inBackend Admin Systems

PocketBase is an open-source Go backend that bundles all essential features into a single executable file. It is an ideal choice for side projects, internal tools, or mid-sized applications.

Database Included You don't need to manage an external database; PocketBase uses SQLite out of the box. It features built-in real-time subscriptions, meaning connected clients receive instant updates whenever data changes on the server—no manual WebSocket configuration required.

Integrated Files and Users The system includes dedicated modules for file management and user authentication. There is no need to write boilerplate code for file uploads or password resets, as these features are available immediately.

Administrative Dashboard A built-in web interface allows you to manage records, modify schemas, and define access rules without writing any frontend code. This is a significant time-saver during early-stage development.

Predictable REST API The API follows standard REST patterns, making it easy to fetch, create, and update records. Frontend integration is intuitive and straightforward.

To interact with the PocketBase API from your client-side code, use one of the official SDKs:

JavaScript SDK: Available at pocketbase/js-sdk. It supports browsers, Node.js, and React Native.

Dart SDK: Available at pocketbase/dart-sdk. This supports Flutter applications for web, mobile, and desktop, as well as CLI tools.

Running PocketBase as a Standalone App

The simplest way to use PocketBase is to download the pre-built binary for your operating system.

  1. Download the archive from the Releases page.
  2. Extract the contents and run ./pocketbase serve in your terminal.
  3. These binaries are compiled from examples/base/main.go. The JavaScript VM plugin is enabled by default, allowing you to extend the backend with custom logic using JavaScript (refer to the "Extend with JavaScript" documentation).

Using PocketBase as a Go Package

For custom workflows, you can import PocketBase as a library. Your application will still compile into a single portable executable.

Here is a minimal working example:

  1. Install Go 1.23 or newer.
  2. Create a new directory and add a main.go file:
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 {
        // Register a custom route: GET /hello
        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)
    }
}
  1. Run go mod init myapp && go mod tidy.
  2. Start the application with go run main.go serve.
  3. To build a static binary, use CGO_ENABLED=0 go build, then run ./myapp serve.

Building From Source

To compile the executable directly from the source code, follow these steps:

  1. Install Go 1.23+.
  2. Clone the PocketBase repository.
  3. Navigate to examples/base.
  4. Compile the binary (example for Linux amd64): GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build.
  5. Run ./base serve.

The pure-Go SQLite driver supports the following targets:

  • darwin: amd64, arm64
  • freebsd: amd64, arm64
  • linux: 386, amd64, arm, arm64, loong64, ppc64le, riscv64, s390x
  • windows: 386, amd64, arm64