# Deploy to Vercel (/docs/self-hosting)

A Goatside deploy is one Vercel project, built from `apps/goatside`, and one
[Turso](https://turso.tech) database. You'll need a [GitHub](https://github.com) and a
[Vercel](https://vercel.com) account. Everything can be done in the browser. If you'd
rather run the database setup from your computer, you also need Node 24 or newer and
[pnpm](https://pnpm.io).

You can create the database in two ways. Both give Goatside the same two variables, so
the app doesn't care which one you pick.

- **Vercel Marketplace.** Add Turso from your Vercel project's **Storage** tab. Vercel
  bills it and sets the variables for you. No Turso account or CLI.
- **Turso directly.** Create it with the [Turso CLI](https://docs.turso.tech/cli) on your
  own Turso account, then paste the URL and token into Vercel.

## What it costs [#what-it-costs]

| Service    | Cost                                                                        |
| ---------- | --------------------------------------------------------------------------- |
| Vercel     | Free on the Hobby plan, which is for personal, non-commercial use           |
| Turso      | Free plan, with far more room than one person's ledger needs                |
| AI Gateway | $10 of credit, the smallest top-up, plus any card fee. Expires after a year |

Vercel gives every team $5 of free AI Gateway credit a month, but it only covers some
models. Goatside's two aren't among them, so the agent needs credits you buy.

Both models are cheap. Jev, which files your entries, costs $0.042 per million input
tokens, so a hundred entries cost well under a cent. DeepSeek V4.1 Flash, which answers
your questions, costs $0.30 per million input tokens and $1.20 per million output tokens,
about a cent or less per question. Credit expires a year after you buy it, and for one
person, $10 is far more than a year's use. These are
October 2026 prices. The [AI Gateway model list](https://vercel.com/ai-gateway/models)
has current ones.

Skip the credits and Goatside is free to run, without the agent. See
[Running without AI](/docs/guide/privacy#running-without-ai).

## Set it up [#set-it-up]

<Steps>
<Step>

### Fork the repo [#fork-the-repo]

[Fork goatside on GitHub](https://github.com/joshxfi/goatside/fork). To work from your
computer too, clone your fork and install its dependencies:

```sh
git clone https://github.com/<you>/goatside
cd goatside
pnpm install
```

Your fork is what Vercel deploys. Keeping it synced with this repo is how you
[get updates](/docs/self-hosting/updating).

</Step>
<Step>

### Import it in Vercel [#import-it-in-vercel]

In Vercel, choose **Add New → Project** and import your fork. Set **Root Directory** to
`apps/goatside`. Vercel detects TanStack Start and builds it with Nitro. Leave the other
build settings as they are.

Before you deploy, add these under **Environment Variables**:

| Variable            | Value                                                              |
| ------------------- | ------------------------------------------------------------------ |
| `GOATSIDE_USERNAME` | The username you'll sign in with                                   |
| `GOATSIDE_PASSWORD` | A password of 12 or more characters. The app lives on a public URL |
| `SESSION_SECRET`    | 32 or more random characters. Run `openssl rand -base64 32`        |

Then deploy. The app can't open until it has a database, so this first deploy is only
there to create the project.

</Step>
<Step>

### Add the database [#add-the-database]

Pick a location close to where you live. Every request makes a few database calls, so
distance shows up as lag.

<Tabs groupId="database" persist items={["Vercel Marketplace", "Turso directly"]}>
<Tab value="Vercel Marketplace">

In your Vercel project, open **Storage**, choose **Create Database** and pick
**Turso Cloud**. Name the database `goatside`, choose a plan and a region, and connect it
to your project.

Vercel adds `TURSO_DATABASE_URL` and `TURSO_AUTH_TOKEN` to the project's environment
variables. Goatside reads those names, so there's nothing to rename.

</Tab>
<Tab value="Turso directly">

Install the [Turso CLI](https://docs.turso.tech/cli), then create a database and a token
for it:

```sh
turso auth login
turso db create goatside
turso db show goatside --url          # libsql://goatside-<you>.turso.io
turso db tokens create goatside
```

In your Vercel project, open **Settings → Environment Variables** and add:

| Variable             | Value                             |
| -------------------- | --------------------------------- |
| `TURSO_DATABASE_URL` | The URL from `turso db show`      |
| `TURSO_AUTH_TOKEN`   | The token from `turso db tokens…` |

</Tab>
</Tabs>

</Step>
<Step>

### Set up the tables [#set-up-the-tables]

Vercel doesn't migrate the database. Run the migrations from GitHub or from your
computer. Both need the database's URL and token, and
[Database](/docs/self-hosting/database#your-url-and-token) shows where to find them.

<Tabs groupId="migrate" persist items={["GitHub Actions", "Your computer"]}>
<Tab value="GitHub Actions">

1. Open your fork's **Actions** tab and enable workflows. GitHub turns them off on new
   forks.
2. Under **Settings → Secrets and variables → Actions**, add `TURSO_DATABASE_URL` and
   `TURSO_AUTH_TOKEN` as repository secrets.
3. On the **Actions** tab, open **CI**, choose **Run workflow** on `main` and wait for it
   to finish. Its `migrate` job sets up the tables.

From then on, every push to `main` applies new migrations on its own.

</Tab>
<Tab value="Your computer">

From your clone:

```sh
TURSO_DATABASE_URL=<url> \
TURSO_AUTH_TOKEN=<token> \
pnpm db:migrate
```

Run it again whenever an update adds a migration, or switch to GitHub Actions later.

</Tab>
</Tabs>

If you skip this, Goatside opens on a page that says the database has no tables yet.

</Step>
<Step>

### Turn on AI Gateway [#turn-on-ai-gateway]

The agent runs on [Vercel AI Gateway](https://vercel.com/docs/ai-gateway). On Vercel it
signs in with your project's OIDC token, so there's no key to manage.

1. Open **AI Gateway** on your Vercel team's dashboard and enable it.
2. Choose the credits balance in the top right and buy credit. $10 is the smallest
   top-up, and the free monthly credit doesn't cover Goatside's models (see
   [What it costs](#what-it-costs)).
3. Optionally, set a [budget](https://vercel.com/docs/ai-gateway/observability-and-spend/budgets)
   to cap what it can spend.

If the credits run out, entries still save, uncategorized, and the agent can't answer
until you add more. **Auto-reload** in the same dialog, off by default, can refill the
balance for you.

Skip this and Goatside still works, without the agent. See
[Running without AI](/docs/guide/privacy#running-without-ai).

</Step>
<Step>

### Redeploy and sign in [#redeploy-and-sign-in]

Vercel applies new environment variables only to new deployments. Open
**Deployments**, choose **Redeploy** on the latest one, and wait for it to finish.

Open your project's URL and sign in with your username and password. Goatside adds the
default categories the first time you sign in.

Then [install it on your phone](/docs/guide/phone) and log your first entry.

</Step>
</Steps>

## Pick a function region [#pick-a-function-region]

This step is optional. The app is fastest when its function runs near your database. In
your Vercel project, open **Settings → Functions** and set the **Function Region** to the
one closest to your database. For Singapore, that's `sin1`.

## Preview deployments [#preview-deployments]

Vercel adds environment variables to every environment by default, so a preview
deployment of another branch uses your real database. If you push branches to your fork,
limit the Turso variables to **Production**, or give previews a second database.

## If something's wrong [#if-somethings-wrong]

Goatside checks its setup when a page loads. If it can't run, it shows what's missing
instead of an error:

- **Environment variables** that are missing or too short, by name. Fix them under
  **Settings → Environment Variables**, then redeploy.
- **The database can't be opened.** Check `TURSO_DATABASE_URL` and `TURSO_AUTH_TOKEN`,
  then redeploy. The function logs under **Logs** have the exact error.
- **Migrations that haven't run.** Run them, then choose **Check again**. Right after an
  update, GitHub Actions may still be migrating, so the page checks again on its own.

A new password that doesn't work is a different problem. Changes to variables reach only
new deployments, so the old password still applies until you redeploy.
