Scaffold
Scaffold a New Project
Create a new Dex project with dex scaffold <dir>.
Command
dex scaffold <dir> [options]How It Works
When you run dex scaffold <dir>:
- Prepares Destination Directory: Creates
<dir>and verifies it is empty. - Project Type Selection: Uses
--mode <spa|mpa>or interactively prompts you to choose:spa— Single-Page Application template (dex-template-spa.tgz)mpa— Multi-Page Application template (dex-template-mpa.tgz)
- Resolves & Caches Template: Downloads the template archive from GitHub Releases (using the local OS template cache unless
--no-cacheor--freshis passed), a direct--template-url, or a local--template.tgzfile. Archive extraction enforces path-traversal checks (SafeJoin), rejects symlinks/hardlinks, and enforces entry and size limits. - Fetches Framework Packages: Downloads bundled framework package tarballs (
router,server,dev,pie), extracts them intopackages/, createspackages/index.ts, and recordsdex.packageVersionsinpackage.json. - Initializes Metadata: Creates
.dex/metadata.jsonto track the template version and release tag for futuredex syncupdates. - Verifies Project Structure: Checks that
package.json,dex.config.*, andpackages/*are present. - Installs Dependencies: Runs
bun installinside<dir>(unless--no-installis passed).
Options
| Option | Description | Default |
|---|---|---|
--mode <spa|mpa> | Skip interactive prompt and select project type | Interactive prompt |
--repo <owner/repo> | GitHub repository containing template release assets | patrickaigbogun/dex |
--tag <tag|latest> | Release tag to download template from | latest |
--packages-repo <owner/repo> | GitHub repository containing dex-package-*.tgz assets | Template repository |
--packages-tag <tag|latest> | Release tag for dex-package-*.tgz assets | Template tag |
--template <path> | Path to a local .tgz archive (skips GitHub API) | — |
--template-url <url> | Direct URL to download template .tgz (skips GitHub API) | — |
--no-install | Skip running bun install during scaffolding | false |
--no-cache, --fresh | Bypass the local template cache and download fresh release assets | false |
Examples
Basic Scaffolding
# Scaffold in a new directory
dex scaffold my-blog
# Navigate to the project and start development
cd my-blog
dex startBypass Local Cache (--no-cache / --fresh)
# Force fresh downloads from GitHub Releases instead of cached tarballs
dex scaffold my-blog --fresh
# or
dex scaffold my-blog --no-cacheSpecify Release Tag, Mode, or Custom Repository
# Pin to a specific release tag non-interactively
dex scaffold my-blog --mode spa --tag v0.2.6
# Use templates from a custom repository
dex scaffold my-blog --repo myorg/dex-templates --tag v1.0.0Offline / Local Archive Scaffolding
# Use a pre-downloaded template archive and skip dependency installation
dex scaffold my-blog --template ./dex-template-spa.tgz --no-install
cd my-blog
bun installDirect URL Scaffolding
dex scaffold my-blog --template-url https://example.com/templates/dex-template-spa.tgzWhat Gets Created
my-blog/
├─ .dex/
│ └─ metadata.json # Template version and sync tracking
├─ dex.config.ts # Dex framework configuration
├─ package.json # Dependencies and scripts
├─ tsconfig.json # TypeScript configuration
├─ core/
│ ├─ bootstrap/ # dev.ts, build.ts, web.tsx
│ └─ runtime/ # Dev and prod Elysia server entrypoints
├─ packages/ # Bundled Dex framework modules
│ ├─ router/ # File-based router package
│ ├─ server/ # Server runtime package
│ ├─ dev/ # Dev server and build tool package
│ ├─ pie/ # Typed API client package
│ └─ index.ts # Package re-exports
├─ web/
│ ├─ pages/ # File-based route components
│ ├─ layouts/ # Layout components
│ └─ public/ # Static assets and index.html
└─ routes/ # Backend API routesNext Steps
- Start development server:
dex start(orbun run dev) - Edit pages in
web/pages/ - Build for production:
dex build(orbun run build) - Run in production:
dex start -p(orbun run start) - Keep your project updated with upstream template fixes:
dex sync
See Also
- CLI Commands — Full CLI command reference
- Your First App — Step-by-step tutorial
- CLI Flags Reference — Flag summary