> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sevalla.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These are the docs for Sevalla, a platform for deploying applications, databases, static sites, object storage and load balancers. The dashboard is at https://app.sevalla.com.
> Bold text in steps is an exact dashboard label.
> To act on a Sevalla account, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md), then the Sevalla CLI (https://docs.sevalla.com/developer-tools/cli.md), then the REST API (https://api-docs.sevalla.com, OpenAPI spec at https://api.sevalla.com/v3/openapi.json).
> Every page index is at https://docs.sevalla.com/llms.txt.

# Deploy a MakerKit application

> Deploy the MakerKit Next.js SaaS starter kit to Sevalla: Ingot builds its pnpm monorepo, PostgreSQL over an internal connection, uploads in object storage, Stripe webhooks and a custom domain.

A MakerKit project runs on Sevalla as one Next.js application: [Ingot](https://docs.sevalla.com/applications/builds/ingot.md) builds the web app from the pnpm monorepo, and the web process serves the site and its API on the port in the `PORT` environment variable. Its data lives in a Sevalla PostgreSQL database that the application reaches over an internal connection, and uploaded files go to an object storage bucket, so they survive every deployment.

[MakerKit](https://makerkit.dev) is a Next.js SaaS starter kit: a TypeScript codebase you own, on the Next.js App Router with Better Auth, Drizzle ORM, PostgreSQL, Stripe and Tailwind CSS with shadcn/ui. It includes team accounts with role-based permissions, subscription billing, transactional email, file storage, a super admin panel and rules files for AI coding assistants.

> [!NOTE]
>
> MakerKit also offers kits built on TanStack Start. They deploy the same way, with different build settings and environment variables. See [Deploy a TanStack Start application](https://docs.sevalla.com/guides/javascript/tanstack-start.md) for the framework's side.

## At a glance

| | |
| - | - |
| Source | A private Git repository with your MakerKit code |
| Build | [Ingot](https://docs.sevalla.com/applications/builds/ingot.md) (Node.js, pnpm, Next.js), with `INGOT_APP` set to `apps/web` |
| Start command | The `start` script of the `apps/web` package, which Ingot detects |
| Port | The `PORT` environment variable, `8080` by default |
| Processes | Web process |
| Services | PostgreSQL 18 over an internal connection; a bucket with public access for uploads |
| Disk | None |
| Health check | `GET /api/healthcheck`, no authentication: `200` with the body `OK`. It checks the web server, not the database. |
| Size | **H1** for the web process, or a larger size to add a custom domain |

### Environment variables

Keep each variable at its default availability, **Available during runtime** and **Available during buildtime**. Next.js compiles `NEXT_PUBLIC_*` variables into the browser code during the build, so a variable that only exists at runtime reaches the browser as `undefined`.

| Variable | Required | Available during | Secret | Value |
| - | - | - | - | - |
| `INGOT_APP` | Yes | Build and runtime | No | `apps/web` |
| `DATABASE_URL` | Yes | Build and runtime | Yes | `DB_URL` from the internal connection, renamed: `postgres://<user>:<password>@<host>:5432/<database>` |
| `NEXT_PUBLIC_SITE_URL` | Yes | Build and runtime | No | The application's address, such as `https://makerkit-app-x7k2m.sevalla.app`, or your custom domain |
| `BETTER_AUTH_SECRET` | Yes | Build and runtime | Yes | Generate with `openssl rand -base64 32` |
| `STORAGE_PROVIDER` | Yes | Build and runtime | No | `s3` |
| `STORAGE_BASE_URL` | Yes | Build and runtime | No | The bucket's **Public domain** with `https://`, such as `https://makerkit-media-q8w2e.sevalla.storage`: the public URL files are read from, not the S3 API endpoint |
| `STORAGE_S3_ENDPOINT` | Yes | Build and runtime | No | The bucket's **Endpoint**, such as `https://<account-id>.r2.cloudflarestorage.com`, without the bucket name |
| `STORAGE_S3_ACCESS_KEY_ID` | Yes | Build and runtime | Yes | The bucket's **Access key** |
| `STORAGE_S3_SECRET_ACCESS_KEY` | Yes | Build and runtime | Yes | The bucket's **Secret key** |
| `STORAGE_S3_BUCKET` | Yes | Build and runtime | No | The bucket's **Bucket name**, such as `makerkit-media-q8w2e`, not its display name |
| `STORAGE_S3_REGION` | Yes | Build and runtime | No | `auto` |
| `NEXT_PUBLIC_BILLING_PROVIDER` | Yes | Build and runtime | No | `stripe` |
| `STRIPE_SECRET_KEY` | Yes | Build and runtime | Yes | Your Stripe secret key: `sk_live_...`, or `sk_test_...` for a staging deployment |
| `STRIPE_WEBHOOK_SECRET` | Yes | Build and runtime | Yes | The signing secret of your Stripe webhook endpoint, `whsec_...`. See [Connect Stripe webhooks](#connect-stripe-webhooks). |
| `MAILER_PROVIDER` | Yes | Build and runtime | No | `resend`, or `nodemailer` for your own SMTP server |
| `RESEND_API_KEY` | With `resend` | Build and runtime | Yes | Your Resend API key |
| `EMAIL_SENDER` | Yes | Build and runtime | No | The sender address, such as `noreply@example.com` |

With `MAILER_PROVIDER=nodemailer`, replace `RESEND_API_KEY` with `EMAIL_HOST`, `EMAIL_PORT`, `EMAIL_USER`, `EMAIL_PASSWORD` and `EMAIL_TLS`. A feature you turned on locally, such as social login, captcha, feature flags or error monitoring, comes with variables of its own, which the Dev Tools list in [Prepare the project for Sevalla](#prepare-the-project-for-sevalla) includes.

The internal connection also adds `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME` and `DB_PASSWORD`, which MakerKit doesn't read.

## Before you begin

* A Sevalla company with a payment method, and a GitHub, GitLab or Bitbucket account for the repository. See [Git providers](https://docs.sevalla.com/git/overview.md).
* A MakerKit license, and your MakerKit codebase in a private repository on that Git provider.
* Node.js and pnpm on your computer, at the versions your MakerKit project requires. You use them to apply the database migrations.
* A Stripe account with API keys, and either a Resend API key or SMTP credentials for outgoing email.

The database and the bucket are created in Sevalla during this guide, so nothing needs to exist elsewhere first.

## Prepare the project for Sevalla

MakerKit is a pnpm monorepo: the deployable Next.js app is `apps/web`, next to shared packages. Ingot installs the whole workspace from the lock file at the repository root, so commit `pnpm-lock.yaml`, and builds the app that `INGOT_APP` names. The repository needs no other change.

Leave the application's **Build path** at `.`. With `INGOT_APP`, the build path is the root of the workspace, and `INGOT_APP` is the app's folder relative to it. See [Build an application in a monorepo](https://docs.sevalla.com/applications/builds/ingot.md#build-an-application-in-a-monorepo).

Production variables are easy to forget. Instead of writing a `.env` file by hand, let MakerKit's Dev Tools list exactly what your configuration requires:

```bash theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
pnpm --filter dev-tool dev
```

Open `http://localhost:3010/variables`, select **Production** mode, fill in the variables it highlights as missing, and click **Copy**. You paste the list into Sevalla in [Deploy to Sevalla](#deploy-to-sevalla). It holds live credentials, so if you save it to a file, keep that file out of Git.

## Deploy to Sevalla

**1. Create the database**

In the sidebar, click **Databases**, then click **Create database**. Under **Database**, choose **PostgreSQL** and version 18, the version this guide was tested with. Enter `makerkit-db` as the **Display name**, choose a **Data center** and a **Size**, then click **Create database**. Remember the data center: the application must be in the same one to reach the database over the private network. See [Create a database](https://docs.sevalla.com/databases/create.md) for every field.

**2. Create the bucket**

MakerKit's local-filesystem storage driver is for development only, and an application's local files are replaced on every deployment and restart, so uploads need a bucket.

In the sidebar, click **Object storage**, then click **Create object storage**. Enter `makerkit-media` as the **Name**, choose the **Location** closest to the database, and click **Create object storage**. Click the bucket's **Settings** tab, then click **Enable public access** under **Public access** and click **Enable public access** in the dialog. See [Create a bucket](https://docs.sevalla.com/object-storage/create.md) and [Public access](https://docs.sevalla.com/object-storage/settings.md#public-access).

Public access makes every object in the bucket readable by anyone who has its URL. MakerKit uses this bucket for profile pictures and organization logos, so keep sensitive documents out of it. If your product handles private files, store them in a separate bucket with public access left off.

Leave the **Settings** tab open: the environment variables need its **Bucket name**, **Endpoint**, **Access key**, **Secret key** and **Public domain**.

**3. Create the application**

In the sidebar, click **Applications**, then click **Create** > **Application**. Under **Source**, click **Private repository**, then choose the **Git provider**, the **Repository** and the **Branch** you release from. Enter `makerkit-app` as the **Name**. Under **Location**, choose the same **Data center** as the database. Keep the **Size** at **H1** or choose a larger one, then click **Create application**. To launch on your own domain, choose a size larger than **H1**: custom domains aren't available on the Hobby size. The application opens on its **Overview** tab with the status **Not deployed yet**.

Creating an application doesn't deploy it, so you can add its variables before the first build. Add them first: a build without them ships a bundle that's missing every `NEXT_PUBLIC_*` value.

**4. Connect the database**

Click the **Networking** tab. Under **Connected services**, click **Add internal connection**. Choose `makerkit-db` as the **Service** and turn on **Add environment variables to the application**. In the list of variables, change the key `DB_URL` to `DATABASE_URL`, then click **Add internal connection**. See [Connect an application](https://docs.sevalla.com/databases/connect.md#connect-an-application).

MakerKit's build doesn't connect to the database, so `DATABASE_URL` only needs the internal connection at runtime.

**5. Add the environment variables**

Click the **Environment variables** tab, then click **Add environment variables**. Paste the list you copied from the Dev Tools into a key field, or click **Import .env** and pick the file you saved it to. Then check each variable against the table in [Environment variables](#environment-variables):

* Add `INGOT_APP` with the value `apps/web`. Ingot reads only variables that are **Available during buildtime**.
* Keep the `DATABASE_URL` that the internal connection added: delete any pasted `DATABASE_URL` that holds a local or external address.
* Set `NEXT_PUBLIC_SITE_URL` to the address the application will have in the browser, scheme included and without a trailing `/`. Better Auth treats it as the canonical address, and MakerKit builds every email link, OAuth redirect and Stripe return URL from it. Until you add a custom domain, use the application's Sevalla domain, shown under its name, such as `https://makerkit-app-x7k2m.sevalla.app`.
* Fill in the bucket values from the bucket's **Settings** tab: `STORAGE_S3_BUCKET` takes the **Bucket name**, not the display name, and `STORAGE_S3_REGION` is `auto`, because Sevalla buckets run on Cloudflare R2. `STORAGE_S3_ENDPOINT` takes the **Endpoint** as shown, without the bucket name: MakerKit always sends path-style requests, so R2 needs no other setting.
* Generate `BETTER_AUTH_SECRET` for this deployment with `openssl rand -base64 32`, and don't copy the one from your computer.

Click **Add environment variables**. See [Environment variables](https://docs.sevalla.com/applications/environment-variables.md).

> [!WARNING]
>
> Don't add `NODE_ENV=test`, `TEST` or `NEXT_PUBLIC_CI=true`. In production, Better Auth rejects requests from foreign origins, refuses unknown callback URLs and rate limits the auth endpoints, which blocks CSRF and open-redirect attacks. These protections relax in test environments by design.

**6. Apply the database migrations**

The new database is empty. You apply MakerKit's migrations from your computer, through the database's external connection.

In the sidebar, click **Databases**, click `makerkit-db`, then click the **Networking** tab. Under **Public networking**, in **External connection**, click **Enable**, then click **Enable** in the dialog. Copy the **External connection URL** when it appears. See [Enable the external connection](https://docs.sevalla.com/databases/connect.md#enable-the-external-connection).

In your local MakerKit checkout, start the migration:

```bash theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
read -s DATABASE_URL && export DATABASE_URL && pnpm --filter "@kit/database" drizzle:migrate
```

The terminal waits. Paste the external connection URL and press Enter. Because of `read -s`, the connection string isn't echoed to the screen or saved in your shell history. When the migration finishes without errors, you can click **Disable** in **External connection** to close the public connection again.

**7. Deploy**

Check these before the first deployment:

* `DATABASE_URL` holds the internal connection's URL, not the external one.
* `NEXT_PUBLIC_SITE_URL` starts with `https://` and doesn't end with `/`.
* `BETTER_AUTH_SECRET` was generated for this deployment.
* Every `STORAGE_*` variable is filled in.
* The Stripe keys start with `sk_live_`, unless this is a staging deployment.
* None of the test variables named in the environment variables step are present.
* The migration command finished without errors.

Click the **Overview** tab, then click **Deploy now** under **Recent deployments**. Check the **Branch** and click **Deploy**.

**8. Turn on auto-deploy**

To deploy every push to the branch automatically, click the **Settings** tab, then click **Update auto-deploy** in the **Auto-deploy** section. Turn on **Auto-deploy** and click **Update auto-deploy**. See [Deployments](https://docs.sevalla.com/applications/deployments.md#deploy-automatically-on-push).

![The Add environment variables sheet with key and value rows, Add another, Import .env and the availability options](https://assets.sevalla.com/screenshots/light/app-environment-variables-add.png)

## Verify the deployment

1. On the **Deployments** tab, click the deployment. Its **Build log** shows Ingot's [build plan](https://docs.sevalla.com/applications/builds/ingot.md#read-the-build-plan) with the package manager (pnpm) and framework (Next.js) it detected. Wait for the deployment's status to change to **Deployed**. The application's status next to its name changes to **Running**.

2. Check the application's health endpoint:

   ```bash theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
   curl https://makerkit-app-x7k2m.sevalla.app/api/healthcheck
   ```

   A healthy application answers:

   ```text theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
   OK
   ```

   The route needs no authentication and checks only the web server: it answers `200` with `OK` even when the database can't be reached. Step 3 checks the database, because signing in reads it.

3. Open the application's domain, for example `https://makerkit-app-x7k2m.sevalla.app`, sign in or create an account, and upload a profile picture. The file appears on the bucket's **Objects** tab.

4. Deploy again with **Deploy now**. When the deployment is **Deployed**, the picture still loads: the file is in the bucket, not on the instance's disk, which each deployment replaces.

![The application header with its name, Running status, repository, branch and the domain that opens the application](https://assets.sevalla.com/screenshots/light/app-overview-address.png)

A failed deployment almost always points to a variable that's missing or mistyped. Search the deployment's build log for the variable name, correct it on the **Environment variables** tab and deploy again. See [Troubleshoot](#troubleshoot) and [Troubleshoot builds and deployments](https://docs.sevalla.com/applications/troubleshooting/builds-and-deployments.md).

## Add a custom domain

The application already works on its Sevalla domain. To serve it from your own domain, such as `app.example.com`, the web process needs a size larger than **H1**, so [scale](https://docs.sevalla.com/applications/scaling.md) it first.

**1. Add the domain**

On the application's **Domains** tab, click **Add custom domain**, enter the domain in **Domain name** and click **Add custom domain**.

**2. Verify and point the domain**

At your DNS provider, add the two `TXT` records that the **Verify domain** step shows, then add the `A` record that the **Point domain** step shows. If your domain's DNS is on Cloudflare, the records differ: see [Domains on Cloudflare DNS](https://docs.sevalla.com/domains/overview.md#domains-on-cloudflare-dns). Wait for the domain's status to change to **Active**. Sevalla issues and renews the SSL certificate.

**3. Update the site URL**

On the **Environment variables** tab, change `NEXT_PUBLIC_SITE_URL` to the new domain, then deploy again. The old address is compiled into the current build, so only a new build replaces it.

See [Custom domains](https://docs.sevalla.com/domains/overview.md).

## Connect Stripe webhooks

In the Stripe dashboard, create a webhook endpoint for this address, with your own domain:

```text theme={"theme":{"light":"github-dark-default","dark":"github-dark-default"}}
https://app.example.com/api/auth/stripe/webhook
```

Stripe shows a signing secret for the endpoint. Set it as `STRIPE_WEBHOOK_SECRET` on the **Environment variables** tab, then deploy again. MakerKit's [Stripe setup](https://makerkit.dev/docs/nextjs-drizzle/billing/stripe-setup) lists the events to subscribe to and the remaining billing settings, which you finish before you take live payments.

## Deploy changes

With **Auto-deploy** on, every push to the branch starts a deployment; otherwise, click **Deploy now** for each change. Each deployment builds the image, then replaces the web process's instances. See [Deployments](https://docs.sevalla.com/applications/deployments.md).

* After you change an environment variable, click **Deploy now** to redeploy the current commit. A `NEXT_PUBLIC_*` variable is built into the browser code, so it must be **Available during buildtime**, and a change needs a new build.
* When a release adds a migration, apply it as in [Deploy to Sevalla](#deploy-to-sevalla) before the deployment that needs it. To keep the database one step ahead of the code, run the migration as a CI job before the deployment.
* To undo a release, roll back to the previous successful deployment. If the bad release changed the schema, check that the older code can still read it first.

## Troubleshoot

| Symptom | Cause | Fix |
| - | - | - |
| Ingot builds the wrong package, or none | `INGOT_APP` is missing or isn't **Available during buildtime**, or the **Build path** isn't `.` | Set `INGOT_APP` to `apps/web` and leave the **Build path** at `.`, then deploy. |
| Sign-in sends visitors to an unexpected address | `NEXT_PUBLIC_SITE_URL` still holds an old address | Set the current address, then deploy again: the value is built into the application. |
| The application can't reach PostgreSQL | The internal connection is missing, or the application and the database are in different data centers | Add the connection on the application's **Networking** tab, and keep both in the same **Data center**. |
| Your computer can't reach PostgreSQL for the migration | The database's external connection is off | Enable **External connection** on the database's **Networking** tab. |
| Uploaded images disappear after a deployment | The application writes to its local disk | Set `STORAGE_PROVIDER` to `s3` and add the bucket variables, then deploy. |
| Uploads fail with an access error | `STORAGE_S3_BUCKET` holds the bucket's display name | Set it to the **Bucket name** from the bucket's **Settings** tab, then deploy. |
| **Add custom domain** is disabled, or `Custom domains aren’t available on the Hobby size.` | The web process is on the **H1** (Hobby) size | [Scale](https://docs.sevalla.com/applications/scaling.md) the web process to a larger size. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.