Generated patterns
Code the CLI actually writes
Illustrative snippets aligned with Arche presets—not a live sandbox. For full flows, start with getting started or a walkthrough.
Loading highlighted examples...
Illustrative snippets aligned with Arche presets—not a live sandbox. For full flows, start with getting started or a walkthrough.
Typed API with Zod input and protected context.
import { z } from "zod";
import { protectedProcedure, router } from "../trpc";
export const userRouter = router({
getProfile: protectedProcedure
.input(z.object({ id: z.string() }))
.query(async ({ ctx, input }) => {
return ctx.db.user.findUnique({
where: { id: input.id },
});
}),
});Server function consumed from Next.js.
import { query } from "./_generated/server";
import { v } from "convex/values";
export const listPosts = query({
args: {},
handler: async (ctx) => {
return await ctx.db.query("posts").collect();
},
});HTTP route in the generated API crate.
use axum::{Json, Router, routing::get};
use serde::Serialize;
#[derive(Serialize)]
struct Health { ok: bool }
async fn health() -> Json<Health> {
Json(Health { ok: true })
}
pub fn router() -> Router {
Router::new().route("/health", get(health))
}On-chain program entry pattern.
use anchor_lang::prelude::*;
declare_id!("ReplaceWithProgramId");
#[program]
pub mod my_program {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
Ok(())
}
}Non-interactive scaffold payload.
{
"projectName": "my-app",
"destinationDir": "/tmp/my-app",
"preset": "typescript-fullstack",
"packageManager": "bun",
"initializeGit": false,
"installDependencies": false
}