Quick Start
From zero to a working backend in 5 commands. The first account you create on a project becomes its owner; everyone who signs up after is a member.
1. Create a project
terminal
based new my-app
# → URL: https://my-app.based.yourdomain.com
# → Anon Key: xxxx2. Log in
Auto-creates your account on first login.
terminal
based login my-app -e you@email.com3. Create tables
terminal
based table create posts \
title:text:required \
content:text \
status:text:default=draft
# CRUD instantly available at /api/posts4. Get your env vars
terminal
based env my-app
# NEXT_PUBLIC_BASED_URL=https://my-app.based.yourdomain.com
# NEXT_PUBLIC_BASED_ANON_KEY=xxxx5. Generate types
Pulls your schema from the server and writes based.d.ts. Import it as ./based.
terminal
based typegen6. Use in React
app.tsx
import { createClient, BasedProvider, useQuery }
from "@weirdscience/based-client";
import type { Tables } from "./based";
const based = createClient<Tables>({
url: process.env.NEXT_PUBLIC_BASED_URL!,
anonKey: process.env.NEXT_PUBLIC_BASED_ANON_KEY!,
});
function App() {
return (
<BasedProvider client={based}>
<PostList />
</BasedProvider>
);
}
function PostList() {
const { data, isLoading } = useQuery<Tables, "posts">("posts");
if (isLoading) return <p>Loading...</p>;
return data?.map((p) => <div key={p.id}>{p.title}</div>);
}