Skip to content

Getting started

This integration is built on top of Zod PocketBase to ease the use of PocketBase in your Astro projects by:

  • generating schemas for your selected collections
  • generating a loader that you can use for your content collections
  • generating a middleware that gives you access to the PocketBase SDK in Astro.locals

Installation

Astro includes an astro add command to automate the setup of official integrations. If you prefer, you can install integrations manually instead.

  1. To install astro-pocketbase, run the following from your project directory and follow the prompts:

    Terminal window
    npx astro add astro-pocketbase
  2. You also need to provide 3 environment variables for Astro PocketBase to retrieve your collections:

    Terminal window
    # This will only be available when run on the server!
    ASTRO_POCKETBASE_ADMIN_EMAIL="admin@mydomain.com"
    ASTRO_POCKETBASE_ADMIN_PASSWORD="mypassword"
    # This will be available everywhere!
    PUBLIC_ASTRO_POCKETBASE_URL="https://myproject.pockethost.io"

If you run into any issues, feel free to report them to us on GitHub and try the manual setup instead.