Quick Start

From zero to a working backend in 5 commands.

1. Create a project

terminal
based new my-app
# → URL: https://my-app.based.yourdomain.com
# → Anon Key: xxxx

2. Log in

Auto-creates your account on first login.

terminal
based login my-app -e you@email.com

3. Create tables

terminal
based table create posts \
  title:text:required \
  content:text \
  status:text:default=draft

# CRUD instantly available at /api/posts

4. Get your env vars

terminal
based env my-app
# NEXT_PUBLIC_BASED_URL=https://my-app.based.yourdomain.com
# NEXT_PUBLIC_BASED_ANON_KEY=xxxx

5. Use in React

app.tsx
import { createClient, BasedProvider, useQuery }
  from "@weirdscience/based-client";

const based = createClient({
  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("posts");
  if (isLoading) return <p>Loading...</p>;
  return data?.map(p => <div key={p.id}>{p.title}</div>);
}