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

# Deploy

> Push main to build, migrate and deploy a slate, then open it at its hosted URL.

Deploy a slate by pushing its `main` branch to the ContextLayer Git remote. ContextLayer builds that commit, applies its database migrations, publishes the app and MCP tools, and installs its agent schedules.

Work from the slate checkout created by `init`, which has `origin` set to the slate's repository. You need the saved CLI login configured during [Installation](https://docs.usecontextlayer.com/installation.md) and permission to manage the slate. There is no separate deploy command.

## 1. Check the local changes

If you changed the app, run the checkout's type check and production build:

```sh theme={null}
pnpm typecheck
pnpm build
```

Include any declarations, migrations, and generated database types that the code needs. Local success does not configure hosted accounts or copy local data; those are separate from the deployment.

## 2. Commit your changes

`init` already committed the starter on `main`. If you have not changed it, continue directly to the push. Otherwise, commit the files you want to deploy:

```sh theme={null}
git add .
git commit
```

## 3. Push main

```sh theme={null}
git push -u origin main
```

Git authenticates the push with your saved CLI login. Only the slate's owning user or a member of its owning organization can push. Only a push to `main` starts a build; other branches do not deploy the slate.

A successful push means the repository received the commit. The hosted app changes after the build, migrations, and publication succeed.

## 4. Open the hosted URL

After deployment succeeds, open the hosted URL printed by `init`. Its dashboard link is the management page; the hosted URL is the running app.

New slates are private. Sign in with an account allowed to view the slate: its owning user or a member of its owning organization. If a coding agent is deploying for you, it should give you the hosted URL so you can open it in your browser.

Check the behavior you changed in the hosted app. Configure any newly declared hosted connections or viewer secrets through the chrome when prompted.

## What the pipeline does

The pipeline takes its source code, declarations, migrations, and schedules from the pushed commit, in this order:

1. **Prepare.** ContextLayer reads the commit's declarations and selects the databases to migrate.
2. **Build.** An isolated sandbox installs the committed dependencies and runs `pnpm build`.
3. **Migrate.** The commit's Kysely migrations run against the slate's owner-mode databases and every existing member's viewer-mode databases.
4. **Deploy.** The built app is published to the slate's hosted URL.
5. **Schedules.** The schedules of the slate's agents are installed from the same commit.

> [!WARNING]
>
> A failed migration stops the pipeline: the commit is not deployed and its schedules are not installed. The migration is not retried automatically, and SQL statements that ran before the failure can remain applied.

Migrations run while the previous deployment is still serving, so keep them compatible with that version until the new deployment completes. See [Add a database](https://docs.usecontextlayer.com/how-to/add-a-database.md).

## Configure hosted resources separately

Git carries committed source, declarations, migrations, and generated query types. It does not carry the local resources those files used during development:

| Local state | What to do for the hosted slate |
| - | - |
| Assignments in `.contextlayer/connections.json` | Assign connected accounts through the hosted chrome, CLI, or API. |
| Rows in `.contextlayer/databases` | Use the hosted app to create hosted data; deployment applies the schema, not local rows. |
| Secret values in the local environment | Supply hosted values for the Owner selected by each secret's mode. |

See [Connect an account](https://docs.usecontextlayer.com/how-to/connect-an-account.md) and [Secrets](https://docs.usecontextlayer.com/core-concepts/resources/secrets.md) for hosted configuration.

## The hosted URL

The hosted URL is `https://<name>.contextlayer.xyz/`. `<name>` is the slate's name, which ContextLayer chose when it created the slate. On the hosted slate, the chrome appears above the app: the ContextLayer header that shows who is signed in and what the slate still needs to be set up. See [Use a slate](https://docs.usecontextlayer.com/how-to/use-a-slate.md).


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