Connecting Your App
Every PocketBase instance on PocketBase Cloud exposes a standard PocketBase REST + realtime API over HTTPS. The easiest way to talk to it is the official JavaScript SDK, which works in the browser, Node.js, Deno, Bun, and React Native.
Step 1: Install the SDK
npm install pocketbase
Step 2: Find your instance URL
Using the portal
Open the instance from your project’s PocketBase tab — the detail page lists the API URL and the admin URL.
Using the CLI
pb cloud pb info --name my-app-db # URL, version, admin login
pb cloud pb info --name my-app-db --json # same, machine-readable
Inside a linked directory, plain
pb cloud pb info does it.
Step 3: Create a client
Point the client at that URL:
import PocketBase from "pocketbase";
const pb = new PocketBase("https://<instance-name>.pocketbasecloud.com");
That’s it — no API keys or extra configuration. HTTPS and CORS are already handled by the platform.
Step 4: Make your first request
// list records from a collection
const posts = await pb.collection("posts").getList(1, 20, {
sort: "-created",
});
// fetch a single record
const post = await pb.collection("posts").getOne("RECORD_ID");
// create a record
const newPost = await pb.collection("posts").create({
title: "Hello from PocketBase Cloud",
});
Which operations are allowed for unauthenticated or authenticated users is controlled by each collection’s API rules.
Using environment variables
Hard-coding the instance URL works, but most apps keep it in an environment variable so staging and production can point at different instances:
const pb = new PocketBase(import.meta.env.VITE_POCKETBASE_URL);
If you host your frontend on PocketBase Cloud, set this in your build environment — frontend variables are baked in at build time. Backends read theirs at runtime, from the deployment’s Env Vars page or from the CLI:
pb cloud env set POCKETBASE_URL=https://my-app-db.pocketbasecloud.com \
--target backend --name my-app-api
See backend environment variables.
Checking the API before you wire it up
Using the portal
Each collection’s API preview in the instance’s admin panel shows the exact REST endpoints and lets you copy example requests.
Using the CLI
pb talks to any PocketBase instance, which makes it a quick way to confirm an
endpoint from the shell:
pb use https://<instance-name>.pocketbasecloud.com
pb login # superuser
pb collections ls
pb records ls posts --per-page 5
Note that these commands run as the superuser, so they bypass API rules — use
an unauthenticated curl to see what your app’s users actually get.
Other languages
PocketBase has an official Dart SDK for Flutter apps, and community SDKs for Go, Python, Rust, and more. Any HTTP client works too — the full REST API is documented in your instance’s admin panel under API preview on each collection.