Deno
Use MeshQL on Deno with JSR packages. Hono is the recommended HTTP adapter for Deno.
Prerequisites
Section titled “Prerequisites”- Deno 2+
Install
Section titled “Install”JSR (recommended on Deno):
deno add jsr:@meshql/core jsr:@meshql/http jsr:@meshql/clientdeno add npm:hononpm (via Deno’s npm compatibility):
deno add npm:meshql-core npm:meshql-http npm:meshql-client npm:honodeno.json
Section titled “deno.json”{ "tasks": { "dev": "deno run --allow-net --watch main.ts" }, "imports": { "@meshql/core": "jsr:@meshql/core@^0.1.2", "@meshql/http": "jsr:@meshql/http@^0.1.2", "@meshql/client": "jsr:@meshql/client@^0.1.2", "hono": "npm:hono@^4" }}Server (main.ts)
Section titled “Server (main.ts)”import { Hono } from "hono";import { createMesh, buildSelectSql, type MeshSchema } from "@meshql/core";import { meshHonoRoutes } from "@meshql/http/hono";
const schema: MeshSchema = { entities: { user: { type: {} as { id: number; name: string }, fields: ["id", "name"], table: "users" }, token: { type: {} as { accessToken: string }, fields: ["accessToken"], table: "tokens", columns: { accessToken: "access_token" }, }, }, joins: { "user.tokens": { entity: "token", on: "tokens.user_id = users.id", type: "many", }, },};
const mesh = createMesh(schema);
mesh.resolve("user", async (plan) => { const { sql, params } = buildSelectSql(plan, schema); console.log("[meshql]", sql, params); return [{ user_id: 1, user_name: "Ada", tokens_accessToken: "tok_abc" }];});
const app = new Hono();app.route("/", meshHonoRoutes(mesh, { basePath: "/mesh" }));
Deno.serve({ port: 3001 }, app.fetch);console.log("MeshQL on http://localhost:3001/mesh");deno task devClient test
Section titled “Client test”import { createClient } from "@meshql/client";
const client = createClient({ url: "http://localhost:3001/mesh" });const user = await client.query( { user: { id: true, name: true, tokens: { accessToken: true } } }, { entityId: "1" },);console.log(user);Packages
Section titled “Packages”Core packages are on JSR (@meshql/*) and npm (meshql-*), with Deno, Node, and Bun compatibility:
@meshql/core/meshql-core@meshql/http/meshql-http@meshql/client/meshql-client@meshql/upload/meshql-upload