Getting started

Installation

Add Mortar to a Solid 2 app built with Vite.

Mortar runs in a Solid 2 app built with Vite and @solidjs/vite-plugin 3. If you're starting from scratch, set that up first, with SSR if you want pages rendered on the server.

Install the packages

pnpm add @mortar-kit/core @mortar-kit/admin solid-js @solidjs/web @solidjs/router

Add a theme if you want one, for example:

pnpm add @mortar-kit/theme-midnight

Recent versions of pnpm refuse packages published less than a day ago (its minimumReleaseAge setting). To install a Mortar release the day it comes out, exclude the packages in pnpm-workspace.yaml:

minimumReleaseAgeExclude:
  - '@mortar-kit/*'

Every @mortar-kit package releases at the same version. Before upgrading, read the changelog: its Upgrading notes list what can stop a site from starting, such as a renamed environment variable.

Configure Vite

Add mortarKit() next to the Solid plugin. It only chooses the admin's theme, so leave out theme for the default look.

// vite.config.ts
import { mortarKit } from '@mortar-kit/admin/vite';
import midnight from '@mortar-kit/theme-midnight';
import solid from '@solidjs/vite-plugin';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [
    solid({ start: { renderMode: 'async' }, ssr: true, serverFunctions: true }),
    mortarKit({ theme: midnight }),
  ],
});

TypeScript

Use Solid 2's JSX settings:

{
  "compilerOptions": {
    "jsx": "preserve",
    "jsxImportSource": "@solidjs/web",
    "moduleResolution": "bundler"
  }
}

Next, build a first page in the quick start.