palbase
v0.76.0
Published
Palbase for JavaScript: the web client (palbase/web), the server SDK (palbase/server), an organization's management SDK (palbase/cloud), the backend framework (palbase/backend), AI (palbase/ai) and the CLI (npx palbase).
Maintainers
Readme
palbase
The JavaScript SDK and CLI of Palbase — the backend for web, iOS and Android apps. Every project has auth, storage, realtime, feature flags, notifications, secrets, analytics, AI and in-app purchases; your own TypeScript backend runs on a machine built from a GitHub branch on every push, beside a Postgres database of its own.
npm install palbase| Import | What it is |
|---|---|
| palbase/web | The client for browsers and Next.js, made with the project's publishable key: auth, flags, analytics, consent, web push, payments, in-app purchases, messaging, voice and video calls, the realtime socket, and your backend's typed clients |
| palbase/web/payments-ui | Drop-in PCI-safe web UI components for PaymentIntents, saved cards, closed-loop wallet top-up, and QR spend codes |
| palbase/web/ssr | The signed-in session in cookies, for server-rendered apps |
| palbase/web/paywall | Rendering the project's paywalls on the web |
| palbase/server | The server SDK, made with the secret key: every module's server calls |
| palbase/cloud | An organization's server, with one access token and no CLI: projects, environments, billing, usage and webhooks, and every environment's modules |
| palbase/backend | The framework a Palbase machine runs: modules, controllers, validation, gateways, cron, tasks, webhooks, the database |
| palbase/ai | The project's models, tools, agents and chats |
| npx palbase | The CLI: projects, environments, client apps, payments, in-app purchases catalog, databases, tokens for CI and AI agents |
The typed Postgres layer, palgres, comes with palbase/backend.
In a web app
import { createClient } from "palbase/web";
const pb = createClient({
url: "https://<ref>.palbase.studio", // the environment's address
publishableKey: "pb_<ref>_c…", // Studio › Settings › API keys
});
await pb.auth.signUp({ email, password });
const session = await pb.auth.signIn(email, password);Voice and video calls between your users — Palbase gives the call's state and actions, your app draws the screens:
pb.calls.onIncoming((call) => showRinging(call)); // call.accept(), call.decline()
const call = await pb.calls.video(otherUserId); // pb.calls.voice(...) for voice alone
call.subscribe(() => {
const them = call.state.remote[0];
video.srcObject = them?.stream ?? null; // a <video muted>: their voice plays by itself
shared.srcObject = them?.screen ?? null; // the screen they share, apart from their camera
});
await call.setScreenShare(true); // and setMicrophone, setCamera, switchCamera, leave
const place = pb.calls.place("channel:42"); // a meeting held at a channel of your app
place.subscribe(() => showJoin(place.state.call)); // the call going on there, or null
await place.watch(); // place.start() or place.join(); place.unwatch() when it goesA backend
// src/main.ts
import { PalbaseFactory } from "palbase/backend";
import { AppModule } from "./app.module";
await PalbaseFactory.create(AppModule);// src/me.controller.ts
import { Controller, Get, User, type UserT } from "palbase/backend";
@Controller("/me")
export class MeController {
@Get("")
me(@User() user: UserT) {
return { id: user.id }; // every route needs a signed-in user unless it says otherwise
}
}Push it to the GitHub branch a machine is connected to, and the machine builds and serves it — a machine named backend at https://<ref>.app.palbase.studio.
An organization's server
import { PalbaseCloud } from "palbase/cloud";
const cloud = new PalbaseCloud({ token: process.env.PALBASE_TOKEN }); // an access token, pbo_…, pbe_… or an account token, pbu_…
await cloud.billing.steer({ path: { id: org, project }, body: { plan: "pay_as_you_go" } }); // charged monthly, to the payment account that pays for the org
const { data } = await cloud.project(ref).auth.adminListUsers({ query: { limit: 50 } });The token stays on your server: palbase/cloud refuses to run in a browser.
The CLI
npx palbase login
npx palbase use <project>/<environment>
npx palbase init --db # a backend on palbase/backend, with a schemaDocumentation
- Docs: https://palbase.studio/docs — Quickstart, Web SDK, Backend SDK, CLI
- For AI coding assistants: https://palbase.studio/llms.txt (the index) and https://palbase.studio/llms-full.txt (every page in one file)
- iOS: palbase-swift · Android: palbase-android
Distributed compiled; licensed under the Palbase SDK License (LICENSE).
