Skip to content
Public template

About

Ziex with Database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Ziex App with SQLite

This is a starter template for building web applications with Ziex, a full-stack web framework for Zig. It enables the built-in zx.db SQLite database.

Documentation →

Getting Started

1. Install ZX CLI

Linux/macOS

curl -fsSL https://ziex.dev/install | bash

Windows

powershell -c "irm ziex.dev/install.ps1 | iex"

2. Install Zig

brew install zig # macOS
winget install -e --id zig.zig # Windows

Other platforms →

Project

├── app/
│   ├── assets/         # Static assets (CSS, images, etc)
│   ├── db/
│   │   └── migrations/ # SQL migrations (run via zx.db)
│   ├── main.zig        # Zig entrypoint
│   ├── pages/          # Pages (Zig/ZX)
│   │   ├── layout.zx   # Root layout
│   │   ├── page.zx     # Home page (persists counter in zx.db)
│   │   ├── client.zx   # Client side counter component
│   │   └── ...
│   └── public/         # Public static files (favicon, etc)
├── build.zig           # Zig build script (sqlite enabled)
├── build.zig.zon       # Zig package manager config
└── README.md           # Project info

Database

SQLite is enabled in build.zig:

_ = try ziex.init(b, app_exe, .{
    .app = .{
        .features = .{
            .sqlite = .enabled,
        },
    },
});

The framework opens a local database under the app data directory. Use zx.db from pages and server code:

_ = try zx.db.run("INSERT INTO ziex (count) VALUES (?)", .{0});
const row = try zx.db.row(ctx.arena, struct { count: i64 }, "SELECT count FROM ziex WHERE id = 1", .{});

Usage

Development

zig build dev

App will be available at http://localhost:3000. with hot reload enabled.

Serve Production Build

zig build serve --release=fast

Exporting as Static Site

zig build zx -- export

This will create a dist/ directory with the static export of your app. You can deploy the contents of dist/ to any static hosting provider (Netlify, Vercel, GitHub Pages, etc) or serve it with any static file server.

Deployment

zig build zx -- bundle

This will create a bundle/ directory with the binary and static assets needed to run your app. You can deploy the contents of bundle/ to any VPS.

ZX CLI Commands

zig build zx -- [command] [options]

All ZX CLI commands are available under zig build zx -- [command]. For example, to run auto formatter:

zig build zx -- fmt .

Contributing

Contributions are welcome! Feel free to open issues or pull requests. For feature requests, bug reports, or questions, see the Ziex Repo.

Links

About

Ziex with Database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages