Skip to main content
This guide walks you through installing PocketBase, starting the server, and creating your first database collection. You’ll have a working REST API in under 5 minutes.

Prerequisites

No dependencies required! PocketBase is a single executable that runs on macOS, Linux, Windows, and FreeBSD.

Start your first instance

1

Download and extract

Download the latest release for your platform from GitHub:
2

Start the server

Run PocketBase with the serve command:
You’ll see output like this:
PocketBase creates a pb_data directory to store your database and uploaded files. You can customize this with the --dir flag.
3

Create your admin account

Open your browser and navigate to:
You’ll be prompted to create an admin account. Fill in your email and password—this account lets you manage your database through the Admin UI.
4

Create your first collection

In the Admin UI:
  1. Click New Collection in the sidebar
  2. Choose Base collection (for regular database records)
  3. Name it posts
  4. Click Create
Now add some fields:
  • Click New field and select Plain text
  • Name: title, Check Required
  • Add another Editor field named content
  • Click Save
PocketBase automatically adds id, created, and updated fields to every collection.
5

Test your API

Your REST API is automatically available. Try creating a record:
Fetch all records:
You should see your newly created post in the JSON response.

Build with the Go library

If you want to extend PocketBase with custom logic, you can use it as a Go library. Here’s a minimal example based on the official source:
1

Set up your Go project

2

Create main.go

Create a main.go file with this code from the PocketBase examples:
main.go
This example:
  • Creates a new PocketBase instance with pocketbase.New()
  • Hooks into the OnServe() event to add a custom route
  • Registers a GET /hello endpoint that returns “Hello world!”
  • Starts the application with app.Start()
3

Install dependencies and run

Your server starts with both the standard PocketBase API and your custom /hello route.
4

Test your custom route

You should see: Hello world!
5

Build for production

Create a statically linked executable:
Then deploy your single binary:

Advanced example with plugins

The official PocketBase executable (from releases) is built with additional plugins. Here’s what the full examples/base/main.go includes:
The prebuilt executables include all these plugins, allowing you to extend PocketBase with JavaScript without writing Go code.

Common commands

PocketBase includes several built-in commands:

Create a superuser via CLI

Use a custom port

Enable development mode

Development mode enables:
  • Verbose logging to console
  • SQL query logging
  • Detailed error messages
Don’t use --dev in production—it exposes sensitive information in logs.

SDK integration

Connect to your PocketBase API from the frontend using the official SDKs:

Next steps

Database collections

Learn about collection types, fields, and relations

Authentication

Set up user authentication and OAuth2 providers

File uploads

Handle file uploads and image transformations

Extend with Go

Add custom business logic and API routes

Troubleshooting

Port already in use

If port 8090 is busy, specify a different port:

Permission denied on Linux/macOS

Make the executable runnable:

Database locked error

This happens if multiple PocketBase instances try to access the same pb_data directory. Only run one instance per data directory, or use different --dir paths:
For production deployments, consider using process managers like systemd, Docker, or PM2 to keep PocketBase running reliably.