nurulhudaapon/zx
HTML syntax within your Zig code, just like JSX but for Zig!
7268154f43f5827bf78668e8e79a00f2ebe4db13aff3b54879e7514afaf8c87f1abe22121b8992d404db83c617da1956ac5adc1cb9ba1e434c1cb6fda53dac49d66562006e84dd11211b7ae40db68263A Zig library for building web applications with JSX-like syntax. Write declarative UI components using familiar JSX patterns, transpiled to efficient Zig code.
ZX combines the power and performance of Zig with the expressiveness of JSX, enabling you to build fast, type-safe web applications. ZX is significantly faster than frameworks like Next.js at SSR.
curl -fsSL https://ziex.dev/install | bash
powershell -c "irm ziex.dev/install.ps1 | iex"
brew install zig # macOS
winget install -e --id zig.zig # Windows
pub fn QuickExample(allocator: zx.Allocator) zx.Component {
const is_loading = true;
const chars = "Hello, ZX Dev!";
return (
<main @allocator={allocator}>
<section>
{if (is_loading) (<h1>Loading...</h1>) else (<h1>Loaded</h1>)}
</section>
<section>
{for (chars) |char| (<span>{[char:c]}</span>)}
</section>
<section>
{for (users) |user| (
<Profile name={user.name} age={user.age} role={user.role} />
)}
</section>
</main>
);
}
fn Profile(allocator: zx.Allocator, user: User) zx.Component {
return (
<div @allocator={allocator}>
<h1>{user.name}</h1>
<p>{[user.age:d]}</p>
{switch (user.role) {
.admin => (<p>Admin</p>),
.member => (<p>Member</p>),
}}
</div>
);
}
const UserRole = enum { admin, member };
const User = struct { name: []const u8, age: u32, role: UserRole };
const users = [_]User{
.{ .name = "John", .age = 20, .role = .admin },
.{ .name = "Jane", .age = 21, .role = .member },
};
const zx = @import("zx");
Server Side Rendering (SSR)
Static Site Generation (SSG)
Client Side Rendering (CSR) via WebAssembly (WIP)
Client Side Rendering (CSR) via React
Type Safety
Routing
File-system Routing
Search Parameters
Path Segments
Components
Control Flow
if
if nested
if/else
if/else nested
for
for nested
switch
switch nested
while
while nested
Assets
Copying
Serving
Assets Optimization
Image
CSS
JS
HTML
Middleware
API Endpoints
Server Actions
CLI
init Project Template
transpile Transpile .zx files to Zig source code
serve Serve the project
dev HMR or Rebuild on Change
fmt Format the ZX source code (Alpha)
export Generate static site assets
bundle Bundle the ZX executable with public/assets and exe
version Show the version of the ZX CLI
update Update the version of ZX dependency
upgrade Upgrade the version of ZX CLI
VSCode/Cursor Extension
Syntax Highlighting
LSP Support
Auto Format
Neovim
Syntax Highlighting
LSP Support (Full for Zig, partial for ZX)
Auto Format
Zed
Syntax Highlighting
LSP Support (Full for Zig, partial for ZX)
Auto Format
Contributions are welcome! Currently trying out ZX and reporting issues for edge cases and providing feedback are greatly appreciated.