# Hosted quickstart

From "no account" to a live backend with its URL and key in your app, in about
a minute. There is nothing to configure: region, database engine and keys are
handled for you.

## 1. Sign up

Open [console.scribase.com/signup](https://console.scribase.com/signup) and
choose **Continue with Google**, **Continue with GitHub**, or an email and a
password.

## 2. Add a card

Hosted Scribase starts with one checkout through Dodo Payments (our merchant
of record): a one-time **$1 card check**, **credited to your first invoice**.
After that each project costs $25 a month, billed monthly via Dodo for the most
projects you had at once (see [Pricing and billing](https://docs.scribase.com/docs/pricing.md)).

## 3. Your backend is live

When you come back from checkout the console creates, without asking anything:

- your **organization**, named from your email (`ada@acme.io` becomes `acme`);
- your first **project**, `my-app`;
- its **`production`** environment: Postgres, Auth, Storage, Realtime (and
  Functions where the deployment runs them).

The **Your backend is live** screen shows the **Project URL** and the
**publishable key** with one-click copy, ready-to-paste setup for supabase-js,
Expo / React Native, Next.js and curl, and each service's status as it wakes.
You never create keys or secrets yourself.

```ts
import { createClient } from '@supabase/supabase-js'

export const supabase = createClient('<Project URL>', '<publishable key>')
```

For Expo put them in `.env` as `EXPO_PUBLIC_SUPABASE_URL` and
`EXPO_PUBLIC_SUPABASE_ANON_KEY`; for Next.js as `NEXT_PUBLIC_SUPABASE_URL` and
`NEXT_PUBLIC_SUPABASE_ANON_KEY`.
The data plane works with the Supabase client libraries, so nothing else in your app changes.

## 4. Moving an existing project? One field

Open the **Move** page
([console.scribase.com/move](https://console.scribase.com/move)) and paste the
database connection string from your current dashboard (its **Connect** panel). The move
starts on paste and shows its progress: tables, rows, users (with their
password hashes, so they keep signing in) and row-level security policies. To
copy storage files too, tick **Also copy storage files** and add the source
project's `service_role` key. The source project is only read.

When it finishes, the console shows the two values to switch your app to
(`SUPABASE_URL`, `SUPABASE_ANON_KEY`); from a terminal,
`scribase apps switch <org> <project>` prints the same for Expo.

## Pricing and limits

There is no project limit. Each project costs **$25 a month**, billed monthly
via Dodo for the most projects you had at once. Idle projects scale to zero.
The console's **Billing** page shows your plan, this period's project count and
every payment. Details are in [Pricing and billing](https://docs.scribase.com/docs/pricing.md) and on
[scribase.com/pricing](https://scribase.com/pricing).

## Manage it from code (optional)

Everything above is also available over the `/v1` API, the SDK and the CLI.

| You need | Value |
|---|---|
| Control API (`SCRIBASE_API_URL`) | `https://api.scribase.com` |
| Credential (`SCRIBASE_ACCESS_TOKEN`) | A personal access token or organization API key, created below |

The examples below use organization `acme`, project `store` and environment
`production`; use the identifiers the console shows for yours.

### Create an access token

In the console, open **Account → Access tokens** and create a token. Copy it
when it is shown — the secret is displayed once and stored only as a hash.

For CI and services, prefer an **organization API key** (**Organization → API
tokens**) scoped to what the job needs: `read`, `deploy`, or `admin`.

Both are also available over the API; see
[Access tokens & API keys](https://docs.scribase.com/docs/api/tokens.md).

```sh
export SCRIBASE_API_URL=https://api.scribase.com
export SCRIBASE_ACCESS_TOKEN=scb_pat_...   # the token you just copied
```

### Make your first call

With plain HTTP:

```sh
curl -H "Authorization: Bearer $SCRIBASE_ACCESS_TOKEN" \
  "$SCRIBASE_API_URL/v1/environments?organization_id=acme"
```

With the SDK (`npm install scribase`; see [SDK installation](https://docs.scribase.com/docs/sdk.md#installation)):

```ts
import { ScribaseClient } from 'scribase';

const scribase = new ScribaseClient({
  baseUrl: process.env.SCRIBASE_API_URL ?? 'https://api.scribase.com',
  token: process.env.SCRIBASE_ACCESS_TOKEN ?? '',
});

const environments = await scribase.environments.list({ organizationId: 'acme' });
console.log(environments.map((env) => `${env.environment_id}: ${env.phase}`));
```

With the CLI (see [installation](https://docs.scribase.com/docs/getting-started.md)):

```sh
scribase doctor                          # checks the URL and token
scribase env get acme store production
```

### Create a preview for a pull request

```sh
# env create <org> <project> <env> <kind> <data-mode> <region> <idempotency-key> [ttl-hours]
scribase env create acme store pr-42 preview sanitized us-east create-pr-42 72
scribase operation get acme <operation-id-from-the-response>
scribase branch register acme store pr-42 --base production
```

The preview is swept automatically when its TTL expires. Renew it with
`POST .../environments/pr-42/renew` or `scribase.previews.renew(...)`.

### Apply migrations

```sh
scribase migrate acme store pr-42 --dir ./migrations          # plan and lint only
scribase migrate acme store pr-42 --dir ./migrations --apply  # run them
```

## Next steps

- [SDK reference](https://docs.scribase.com/docs/sdk.md) — every resource with examples
- [Backups & restore](https://docs.scribase.com/docs/api/backups.md) — verified backups and restore drills
- [Exports](https://docs.scribase.com/docs/api/exports.md) — take the whole stack with you
- [Import an existing project](https://docs.scribase.com/docs/cli/import.md) — move an existing project in
