Getting Started with Staticraft
A complete step-by-step guide to installing Staticraft, creating your first security-first project, understanding the folder structure, and running local development.
1. Prerequisites & Node.js Requirement
Staticraft is built with modern Node.js standard libraries (ES modules, node:fs/promises, node:http). Make sure you have Node.js version 18.0.0 or higher installed. Verify your installed Node version with:
node -v
# Output should be >= v18.0.0
2. Installation Methods
You can install Staticraft globally via npm or run commands on-demand with npx without installing globally.
# Option A: Global installation
npm install -g staticraft
# Option B: Run on-demand using npx
npx staticraft dev
3. Understanding Project Directory Architecture
Staticraft enforces clean separation between source files (`src/app/`) and compiled artifacts (`.raft/`). All templates, controllers, and static assets live inside `src/app/`:
my-staticraft-site/
├── staticraft.config.js # Main project settings (siteUrl, outputDir)
├── package.json
└── src/
└── app/
├── page.html # Home page template (Mapped to /)
├── server.js # Home page data hook & revalidate timer
├── 404.html # Custom error page fallback
├── styles.css # Stylesheets (automatically hashed)
└── docs/
├── page.html # Documentation index (Mapped to /docs)
└── server.js # Data controller for /docs
4. Launching the Local Dev Server
Run `staticraft dev` inside your project directory. Staticraft spins up a fast development server with live reload and automatic file watching on `http://localhost:4455/`.
staticraft dev
# Custom port override:
staticraft dev --port 5000