Self-Hosted

    The Alinea backend can be hosted on most Javascript runtimes if provided with a database (PostgreSQL, SQLite or Mysql) and a Github authentication token. Commits are persisted to the repository via the Github API. See a list of supported database drivers here.

    Hosting on Vercel

    An example of hosting the backend on Vercel using the included Postgres database. Authentication is provided using basic HTTP authentication. Create the credentials and a Github token and store them in your environment variables.

    app/api/cms/route.ts
    import {cms} from '@/cms'
    import {db} from '@vercel/postgres'
    import {createHandler} from 'alinea/next'
    
    const handler = createHandler(cms, {
      database: {
        driver: '@vercel/postgres',
        client: db
      },
      auth(username, password) {
        return (
          username === process.env.ALINEA_USERNAME &&
          password === process.env.ALINEA_PASSWORD
        )
      },
      github: {
        authToken: process.env.ALINEA_GITHUB_TOKEN!,
        owner: process.env.ALINEA_GITHUB_OWNER!,
        repo: process.env.ALINEA_GITHUB_REPO!,
        branch: process.env.ALINEA_GITHUB_BRANCH!,
        rootDir: 'apps/web'
      }
    })
    
    export const GET = handler
    export const POST = handler