> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/pocketbase/pocketbase/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Install PocketBase as a standalone executable or integrate it as a Go library in your project.

PocketBase offers two installation methods depending on your use case. You can use it as a standalone executable for quick deployment, or integrate it as a Go library for custom applications.

## Standalone executable

The fastest way to get started is downloading a prebuilt executable. This is perfect if you want to use PocketBase without writing any code.

<Steps>
  <Step title="Download PocketBase">
    Visit the [GitHub releases page](https://github.com/pocketbase/pocketbase/releases) and download the archive for your platform:

    * macOS (Intel/Apple Silicon)
    * Linux (x86\_64, ARM, ARM64, and more)
    * Windows (x86\_64, ARM64)
    * FreeBSD (x86\_64, ARM64)

    <Note>
      The prebuilt executables include the JavaScript VM plugin by default, allowing you to extend PocketBase with JavaScript hooks.
    </Note>
  </Step>

  <Step title="Extract the archive">
    Extract the downloaded archive to your desired location:

    <CodeGroup>
      ```bash macOS/Linux theme={null}
      unzip pocketbase_VERSION_linux_amd64.zip -d pocketbase
      cd pocketbase
      ```

      ```powershell Windows theme={null}
      Expand-Archive pocketbase_VERSION_windows_amd64.zip -DestinationPath pocketbase
      cd pocketbase
      ```
    </CodeGroup>
  </Step>

  <Step title="Run PocketBase">
    Start the server with a single command:

    <CodeGroup>
      ```bash macOS/Linux theme={null}
      ./pocketbase serve
      ```

      ```powershell Windows theme={null}
      .\pocketbase.exe serve
      ```
    </CodeGroup>

    You should see output indicating the server is running:

    ```text theme={null}
    Server started at: http://127.0.0.1:8090
      - REST API: http://127.0.0.1:8090/api/
      - Admin UI: http://127.0.0.1:8090/_/
    ```
  </Step>

  <Step title="Access the admin UI">
    Open your browser and navigate to `http://127.0.0.1:8090/_/` to set up your admin account and start configuring your database.
  </Step>
</Steps>

### Supported platforms

The pure Go SQLite driver supports these build targets:

<CodeGroup>
  ```text macOS theme={null}
  darwin amd64
  darwin arm64
  ```

  ```text Linux theme={null}
  linux 386
  linux amd64
  linux arm
  linux arm64
  linux loong64
  linux ppc64le
  linux riscv64
  linux s390x
  ```

  ```text Windows theme={null}
  windows 386
  windows amd64
  windows arm64
  ```

  ```text FreeBSD theme={null}
  freebsd amd64
  freebsd arm64
  ```
</CodeGroup>

## Go library installation

Use PocketBase as a Go library to build custom applications with your own business logic. You'll end up with a single executable that includes both PocketBase and your code.

<Steps>
  <Step title="Install Go">
    Make sure you have Go 1.23 or later installed. Check your version:

    ```bash theme={null}
    go version
    ```

    If you need to install Go, visit the [official Go installation guide](https://go.dev/doc/install).
  </Step>

  <Step title="Create a new project">
    Create a directory for your project and initialize a Go module:

    ```bash theme={null}
    mkdir myapp
    cd myapp
    go mod init myapp
    ```
  </Step>

  <Step title="Create your main.go file">
    Create a `main.go` file with the basic PocketBase setup:

    ```go main.go theme={null}
    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)
        }
    }
    ```

    This example creates a PocketBase instance and adds a custom `/hello` route.
  </Step>

  <Step title="Install dependencies">
    Download the PocketBase library and its dependencies:

    ```bash theme={null}
    go mod tidy
    ```
  </Step>

  <Step title="Run your application">
    Start your application in development mode:

    ```bash theme={null}
    go run main.go serve
    ```

    <Info>
      The `serve` command starts the HTTP server. Other available commands include `superuser` for creating admin accounts.
    </Info>
  </Step>

  <Step title="Build a production executable">
    Compile a statically linked binary for deployment:

    ```bash theme={null}
    CGO_ENABLED=0 go build
    ```

    Then run your application:

    ```bash theme={null}
    ./myapp serve
    ```

    <Note>
      Set `CGO_ENABLED=0` to create a fully static binary that doesn't depend on system libraries.
    </Note>
  </Step>
</Steps>

### Cross-compilation

Build executables for different platforms:

<CodeGroup>
  ```bash Linux (x86_64) theme={null}
  GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
  ```

  ```bash macOS (Apple Silicon) theme={null}
  GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build
  ```

  ```bash macOS (Intel) theme={null}
  GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build
  ```

  ```bash Windows (x86_64) theme={null}
  GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build
  ```
</CodeGroup>

## Configuration options

Both installation methods support the same command-line flags:

| Flag              | Default       | Description                                        |
| ----------------- | ------------- | -------------------------------------------------- |
| `--dir`           | `./pb_data`   | The data directory for database and files          |
| `--dev`           | Auto-detected | Enable development mode with verbose logging       |
| `--encryptionEnv` | None          | Environment variable for encryption key (32 chars) |
| `--queryTimeout`  | 30            | Default SELECT query timeout in seconds            |

### Example usage

```bash theme={null}
# Use a custom data directory
./pocketbase serve --dir=/var/pocketbase/data

# Enable development mode
./pocketbase serve --dev

# Set query timeout
./pocketbase serve --queryTimeout=60
```

## Data directory structure

PocketBase stores all data in a single directory (`pb_data` by default):

```text theme={null}
pb_data/
├── data.db           # Main SQLite database
├── data.db-shm       # Shared memory file (SQLite)
├── data.db-wal       # Write-ahead log (SQLite)
├── logs.db           # Request logs database
└── storage/          # Uploaded files
```

<Warning>
  Back up the entire `pb_data` directory regularly. It contains your database, uploaded files, and application settings.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart guide" icon="rocket" href="/quickstart">
    Create your first collection and API
  </Card>

  <Card title="Extend with Go" icon="code" href="/go/overview">
    Learn how to add custom routes and hooks
  </Card>
</CardGroup>
