Skip to content
Latchkey

CI/CD for a SvelteKit + Vercel App with GitHub Actions

Check, test, build, and deploy your SvelteKit app to Vercel automatically.

SvelteKit with adapter-vercel targets Vercel functions and edge. This recipe runs svelte-check and Vitest, then deploys with the Vercel CLI so PRs get previews and main goes to production.

What the pipeline does

  • install deps with npm ci
  • sync types with svelte-kit sync
  • type-check with svelte-check
  • test with vitest run
  • deploy with the Vercel CLI

The workflow

svelte-kit sync generates the .svelte-kit types before svelte-check. The Vercel CLI builds and deploys; --prod is gated on the default branch.

.github/workflows/ci.yml
name: CI
on:
  push:
    branches: [main]
  pull_request:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
      - run: npm ci
      - run: npx svelte-kit sync
      - run: npx svelte-check --tsconfig ./tsconfig.json
      - run: npx vitest run
      - name: Deploy
        run: |
          npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
          npx vercel build --prod
          npx vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
        if: github.ref == 'refs/heads/main'

Caching and speed

cache: npm restores installs and persisting .svelte-kit with actions/cache speeds type generation. svelte-check plus Vitest run fast, and on cheaper managed runners such as Latchkey (around 69% cheaper than GitHub-hosted) the whole pipeline stays inexpensive, with auto-retry covering Vercel API blips.

Deploying

adapter-vercel packages routes as Vercel functions. vercel deploy --prebuilt ships the prebuilt output; drop the if guard and --prod to give every PR a preview URL via vercel deploy.

Key takeaways

  • Run svelte-kit sync before svelte-check to generate route types.
  • adapter-vercel turns routes into Vercel functions and edge handlers.
  • Gate vercel --prod on the main branch; PRs get preview deploys.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →