From zero to
Hello, world.
One parent page. One reusable component. A few minutes to see how Vitemple fits together.
Start with an empty folder
Use Node.js 22.12+ and npm. The compiler runs locally; your visitors only need a browser.
mkdir hello-vitemple
cd hello-vitemple
npm init -y
npm install vitemple
npm install --save-dev viteAdd your commands
Set the project to ES modules and replace the scripts section in package.json. Keep the dependencies added by npm.
"type": "module",
"scripts": {
"build": "vitemple src/index.html --outdir dist",
"dev": "node node_modules/vitemple/scripts/dev.mjs",
"start": "vite preview"
}Write the parent page
Create src/index.html. The slot points to a component relative to this file.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello Vitemple</title>
</head>
<body>
<slot src="./components/hello.html" />
</body>
</html>Create your first component
Create the components folder inside src, then add hello.html. A component can be just one line.
<h1>Hello, world!</h1>Hello, world!
Your parent page now contains the imported heading.
Open it in your browser
Run the development server and open the URL printed in your terminal, usually http://localhost:5173. Change the heading, save, and watch the browser reload.
npm run devMake it personal
Replace the slot in your parent page, then update the heading in your component. Attributes become build-time placeholders.
<slot src="./components/hello.html" name="Developer" /><h1>Hello, {name}!</h1>Hello, Developer!
Build a page you can ship
Create dist/index.html and preview it. Upload the contents of dist to a static host. No Node.js server is needed in production.
npm run build
npm startHTML → slot expansion → static HTML. Next, add styles or connect components with shared state.