Reference › APIs

Vite plugin

import clarusjs from 'clarusjs/vite'

export default defineConfig({ plugins: [clarusjs()] })

routes

Type: Record<string, 'static' | 'server' | 'client'> · Default: {} (every route is static)

When each route renders. Keys are paths (/about) or folders (/account/*, which also matches /account); the most specific one wins. An unknown mode, or a pattern that doesn't start with /, stops the build. See Rendering modes.

clarusjs({ routes: { '/account/*': 'server' } })

adapter

Type: 'netlify' · Default: none

Where server routes deploy. With 'netlify', vite build writes .netlify/v1/functions/clarusjs-server.mjs (Netlify's Frameworks API, read from the site's package directory: in a monorepo, set Netlify's package directory to the folder with vite.config.ts, and don't also set base to it): a function that calls dist/server/index.mjs for the server routes' paths, with static files served first. With no server routes, no function is written.

fragments

Type: boolean · Default: false

Fragment navigation. Every static and server page also answers at <path>/index.frag.html: its <title> and the element marked data-cl-swap (or its <body>). vite build writes those files next to each static page; server routes serve them from the handler (and, with adapter: 'netlify', from the function).

What it does