Install and a first page
In this lesson you create a project, start the dev server, and change the page it serves. About five minutes.
Read #
A clarusjs site is a Vite project. Pages are .tscl files in src/pages: their path is their URL, so src/pages/index.tscl is / and src/pages/about.tscl is /about.
A page is HTML with holes for values. It becomes static HTML when the site is built, and only the parts you make interactive ship JavaScript.
Create #
Create a project and install it:
mkdir my-site && cd my-site
pnpm init
pnpm add clarusjs
pnpm add -D viteYou need Node 22.12 or later.
Add the plugin to vite.config.ts:
vite.config.ts
tsimport { defineConfig } from 'vite'
import clarusjs from 'clarusjs/vite'
export default defineConfig({ plugins: [clarusjs()] })Write #
Create src/pages/index.tscl with a heading and a value in a hole:
src/pages/index.tscl
tscl<h1>Hello</h1>
<p>Built in {{ new Date().getFullYear() }}.</p>Hello
Built in 2026.
Run #
Start the dev server and open the address it prints:
pnpm viteChange the heading and save: the page updates. Then build the static site with pnpm vite build; the page is in dist/client/index.html.
Quiz #
Where does the page for /about live?
Show the answer
Answer: src/pages/about.tscl
A page's path under src/pages is its URL: src/pages/about.tscl is /about, and src/pages/index.tscl is /.
Done #
You have a project, a page, and a build. Next: templates, with values, lists and conditions.
In the docs: Getting started, Pages and routes.