with one click
new-api
// Scaffold a new merjs API route. Use when the user wants to create a new API endpoint.
// Scaffold a new merjs API route. Use when the user wants to create a new API endpoint.
| name | new-api |
| description | Scaffold a new merjs API route. Use when the user wants to create a new API endpoint. |
| argument-hint | [route-name] |
| disable-model-invocation | true |
Scaffold a new API route at api/$ARGUMENTS.zig.
api/$ARGUMENTS.zig with this template:const mer = @import("mer");
const Response = struct {
// Define your response fields here
message: []const u8,
};
pub fn render(req: mer.Request) mer.Response {
return mer.typedJson(req.allocator, Response{
.message = "hello",
});
}
zig build codegen to regenerate routes/api/$ARGUMENTSapi/ and map to /api/...mer.typedJson(allocator, value) to return typed JSON responsesmer.json(string) for raw JSON stringsreq.body, method via req.methodreq.query_stringreq.cookie("name")const dhi = @import("dhi_validator");pub const metaAdd streaming SSR to a merjs page. Use when the user wants shell-first rendering, skeleton placeholders, or parallel data fetching that resolves inline.
Full production build โ codegen, compile, prerender, and prepare for deployment.
Build and start the merjs dev server with hot reload. Use when the user wants to run, start, or serve the project.
Scaffold a new merjs page. Use when the user wants to create a new page, route, or view.
Work with the merjs Zig web framework. Use when creating pages, API routes, WASM modules, or modifying the merjs build system. Provides conventions for file-based routing, SSR, dynamic routes, type-safe APIs via dhi, sessions, and Cloudflare Workers deployment.