This section of the documentation is still work in progress and soon will be updated with more examples and details.
Please be patient while we work on the ongoing users and profiles refactoring as part of issue #376 .

The biggest difference from other backend solutions like Firebase, Supabase, Nhost, etc., is that PocketBase actually could be used as a Go framework that enables you to build your own custom app specific business logic and still have a single portable executable at the end.

The minimal PocketBase application looks like this:

package main import ( "log" "github.com/pocketbase/pocketbase" ) func main() { app := pocketbase.New() if err := app.Start(); err != nil { log.Fatal(err) } }

Running/building the application is the same as for any other Go program, aka. just go run ... and go build.

PocketBase embeds SQLite, but doesn't require CGO.
If CGO is enabled, it will use mattn/go-sqlite3 driver, otherwise - modernc.org/sqlite.
Enable CGO only if you really need to squeeze the read/write query performance at the expense of complicating cross compilation.


PocketBase could be extented by:

  • Binding to event hooks and modifying responses, eg.:
    app.OnRecordBeforeUpdateRequest().Add(func(e *core.RecordEvent) error { log.Println(e.Record.Id) return nil })
  • Registering custom routes, eg:
    app.OnBeforeServe().Add(func(e *core.ServeEvent) error { e.Router.AddRoute(echo.Route{ Method: http.MethodGet, Path: "/api/hello", Handler: func(c echo.Context) error { return c.String(200, "Hello world!") }, Middlewares: []echo.MiddlewareFunc{ apis.RequireAdminOrUserAuth(), }, }) return nil })
  • Registering custom console commands, eg.:
    app.RootCmd.AddCommand(&cobra.Command{ Use: "hello", Run: func(command *cobra.Command, args []string) { log.Println("Hello world!") }, })
  • and much more...

    You may also find useful checking the repo source and the package documentation .