Guides · Start
Start from code
Talk to a project from your app with @manybases/js, in the browser or on a server.
What you need#
From the project's Deployments → Third-party tab on the dashboard: the project's API URL, and a publishable key (create it there, or use the one your agent created — every publishable key signs users up). Put them in your environment:
NEXT_PUBLIC_MANYBASES_URL=https://proj-<id>.manybases.com/v1
NEXT_PUBLIC_MANYBASES_PUBLISHABLE_KEY=pk_…Install and create a client#
bash
npm install @manybases/jsts
import { createClient } from "@manybases/js";
const mb = createClient(
process.env.NEXT_PUBLIC_MANYBASES_URL!,
process.env.NEXT_PUBLIC_MANYBASES_PUBLISHABLE_KEY!,
);Sign someone up, read and write rows, upload a file#
ts
// Sign up, or sign in. The session is kept for the next calls.
const { data: session, error } = await mb.auth.signup({ email, password });
// Rows: filtered by the table's access preset and this user's identity.
await mb.from("habits").insert({ name: "Run", target_per_week: 3 });
const { data: habits } = await mb.from("habits").list({ order: "created_at.desc", limit: 50 });
// A file, with a link to serve it.
const { data: file } = await mb.storage.upload(blob, { name: "avatar.png", contentType: "image/png" });
console.log(file?.url);Every call returns { data, error } and never throws. error carries code, message, a hint that says what to do, and requestId to find the call in the project's logs.
The two things to know before shipping#
- Who sees which rows is decided by each table's access preset, not by your code: a
privetable shows each user their own rows and nobody else's. Your front end cannot enforce a rule the API does not — the publishable key is public. - The publishable key is shared by every visitor: 300 requests a minute for all of them. The SDK never retries on its own.
Next: the full SDK reference, Host your app elsewhere, or let an agent build the backend for you — Start with an agent.
