Getting started
Install the Sneferu CLI, create a theme with init, preview it with dev, check it with validate and compile it with build.
On this page
Sneferu is the language and SDK for Hekana store themes. A theme is a folder of
HTML-like .snf templates with hk-* tags, a theme.json manifest, locale
files and CSS. The CLI checks it, previews it with sample data and compiles it to
one JSON artifact that Hekana renders.
Prerequisites
| Need | Version |
|---|---|
| Node.js | 20 or newer (node -v) |
| An editor | any; .snf files are HTML, so HTML highlighting works. Format your theme sets up Prettier and format on save |
Create a theme
npx sneferu init my-theme
cd my-themeinit copies the starter theme into my-theme/ and sets theme.json id from
the folder name (my-theme) and name to its title case (My Theme). It refuses a non-empty folder unless you pass
--force.
To skip
npx, install the CLI once:npm i -g sneferu. It is then available assneferu(or the shortsnf), for examplesneferu dev my-theme.npm create sneferu my-themedoes the same asnpx sneferu init my-theme.sneferuis a short name for the@hekana/sneferupackage; both install the same tool.
Start from a template
init takes a template name. The default, starter, is the SDK's own complete
store; the others are finished example themes, each with its own design on every
page.
npx sneferu init my-shop --template arcade
npx sneferu init --list| Template | What you get |
|---|---|
starter | A neutral complete store: header, footer, every page type, tokens to edit. The default |
arcade | Gaming: neon cyan and lime on near-black, for game gift cards and top-ups |
console | Gaming: clean and light, for console games and subscriptions |
esports | Gaming: bold and loud, for tournaments, teams and gear |
creator | Digital: minimal, for a creator selling files, courses and presets |
license | Digital: dark SaaS look, for software licenses and plans |
bento | Digital: soft bento tiles, for apps and templates |
A template is a normal theme folder. It has a template for every page type
(home, product, collection, search, cart, 404, content page), header, footer and
announcement bar as section groups, theme settings, and Arabic and English
locale files, so nothing falls back to the SDK's default store. init sets the
theme id and name from the folder name and leaves everything else yours to
change. sneferu validate, format --check and build pass on a fresh copy.
A name that is not in the list prints the list and exits with an error.
Preview: dev
npx sneferu dev # current folder
npx sneferu dev ./my-theme --port 4200Open http://127.0.0.1:4100. A new theme looks like the picture: the starter's
hero section and a grid of sample products, in English, left to right.
| What | Detail |
|---|---|
| Address | http://127.0.0.1:4100 (local only; --port changes the port) |
| Language | The theme's defaultLocale. ?locale=<code> shows another locale the theme lists in locales |
| Other templates | http://127.0.0.1:4100/__template/<name> renders templates/<name>.snf |
| Live reload | Saving any file recompiles and reloads the open page |
| Errors | A theme that does not compile shows the diagnostics list instead of the page |
| CSS | Every assets/*.css file (top level of assets/) is inlined after the token variables |
| Assets | asset_url('logo.svg') points at /__assets/logo.svg |
The preview uses sample data, not a real store:
| Data | Sample value |
|---|---|
store.name | Sample store |
| Currency | EGP, so money prints EGP 520.00 |
collection('featured'), 'new', 'gift-cards', 'subscriptions' | 4 to 6 products each, with title, url (/products/<handle>, or /en/products/<handle> in English), price (piastres), compare_at, image.url |
product('sample-1') | the first of those products |
| Theme settings | every setting at its default |
| Sections | the default sections listed in the template's <hk-schema> (see chapter 3) |
Any other collection is empty and any other product is nothing, which is a good way to check your empty states.
Your own sample data
To preview with products like your store's, put a .sneferu-dev/data.json in
the theme folder (or pass --data <file>). Folders starting with a dot are never
part of the theme and are never pushed.
{
"store": { "name": "Pages" },
"collections": {
"ebooks": {
"title": "E-books",
"products": [
{ "title": "Notes on design", "url": "/products/notes", "price": 9900,
"compare_at": null, "image": { "url": "https://example.com/notes.png" } }
]
}
}
}| Key | Effect |
|---|---|
store | merged over the sample store, e.g. store.name |
collections | added to the sample collections; a handle you list (even featured) replaces the sample one |
products | added to the product('handle') lookups, keyed by handle; a product has a page at /products/<handle> only when it is listed here |
menus | menus by handle, { "handle", "title", "items": [{ "title", "url", "children"? }] }; they replace the sample main and footer |
Local images in sample data
hk-image renders only https:// and store-relative (/…) URLs, in sneferu dev
and on a store alike. So that sample data can use pictures you have on disk, the
dev server also accepts a relative file path in any image value of
data.json:
{ "products": { "notes": { "title": "Notes", "price": 9900, "image": { "url": "images/notes.webp" } } } }The path is looked up next to data.json first (so put pictures in
.sneferu-dev/images/), then from the theme folder. A file found inside the theme
folder is served under /__dev-images/<path> and shown. Only .png, .jpg,
.jpeg, .webp, .gif, .avif and .svg files inside the theme folder are
served, and only by sneferu dev: nothing about hk-image or a published theme
changes, and these files are not part of the package.
A value that would be dropped (an http:// URL, a //host/… URL, a path with no
file behind it, a path outside the theme folder) is not hidden: sneferu dev
prints a warning naming it, once per value.
For different text per language, split the file by locale:
{ "ar": { "store": … }, "en": { "store": … } }. The file is read on every
request: save it and reload the page. A file that is not valid JSON shows an
error page naming the file.
init writes a complete store: a layout with header, footer and announcement
groups, a template for every page type (home, product, collection, search,
cart, page, 404), the sections, blocks and snippets they use, tokens in
theme.json and assets/theme.css. npx sneferu init --template starter
is the same thing. Everything in it
is editable by the merchant: see Make everything editable.
Check: validate
npx sneferu validate✔ theme [email protected] is validor, with problems, one line per diagnostic and a non-zero exit code:
sections/hero.snf:3:5 error SN2004 unknown property "colour" on <hk-heading>. Did you mean "color"?
✖ 1 error, 0 warningsFormat: file:line:col severity CODE message. Every code is listed in
diagnostics.md. validate exits 0 when valid and 1 when
not, so it can gate CI.
Compile: build
npx sneferu build # → dist/my-theme-0.1.0.sneferu.json
npx sneferu build --out out # another output folderbuild runs the same checks as validate, writes
<out>/<id>-<version>.sneferu.json (the artifact) and copies assets/ to
<out>/assets/. It prints the artifact hash. You do not upload this file:
sneferu push sends the source and Hekana compiles it itself (see
chapter 7).
Commands
| Command | Arguments | Options |
|---|---|---|
init [dir] | folder to create, default my-theme | --force write into a non-empty folder; --template <name> what to scaffold (default starter); --list list the templates. Also writes an AGENTS.md for AI coding agents (see Build themes with AI agents) |
dev [dir] | theme folder, default . | --port <n> default 4100; --data <file> sample data JSON, default .sneferu-dev/data.json when it exists |
validate [dir] | theme folder, default . | |
build [dir] | theme folder, default . | --out <dir> default dist |
format [dir] | theme folder, default . | --check only report files that are not formatted and exit 1 (for CI). Formats .snf files, theme.json and locales/ with Prettier and the Sneferu plugin; see Format your theme |
login | --api-url <url> API to sign in to, default https://api.hekana.com/api/v1. Signs in through the browser and saves a developer key to ~/.config/sneferu/credentials.json; revokes the previously saved key for the same API | |
logout | revokes the saved key on Hekana and deletes the file | |
whoami | prints the account, key prefix and dev store the CLI uses | |
push [dir] | theme folder, default . | --package <slug> required, must equal theme.json id, and not a reserved slug (starter, hekana, default, admin, official, theme, themes, test, demo, preview, and anything starting with hekana-); --dev-store also installs and publishes the version on your dev store and prints its URL. Uses the key saved by login, or env HEKANA_TOKEN; env HEKANA_API_URL |
login, logout, whoami and push are covered in
Get an API key and Push and publish.
Next
- Theme structure: what every file does.
- Sections and blocks: the parts merchants edit.
- Data and expressions:
{{ }}, filters, loops. - Styling and responsive: tokens, CSS, RTL.
- Security and limits: what a theme cannot do.
- Get an API key: developer access,
sneferu login, CI. Push and publish:sneferu push, your dev store, review. - Cookbook: five complete store sections, with pictures.
Format your theme:
sneferu format, Prettier and VS Code. - Tutorial: build a digital products store theme: a whole theme, from mockup to live store. Tutorial: build a gaming store theme: another whole theme, a dark gaming top-up store.
- Tag reference: every
hk-*tag and prop.
