All skills
onmax avatar

/nitro

@de09c7b official
by Maxonmax/nuxt-skills715 stars
38

Nitro is the framework-agnostic server toolkit (powering Nuxt) for building and deploying web servers anywhere. Use when working with nitro.config, server routes/event handlers, route rules, caching, storage, tasks, websockets, or deploying to Node/Bun/Deno/Cloudflare/Vercel.

Use this Skill: https://skilld.dev/gh/onmax/nuxt-skills/nitro

This session only. Nothing lands on disk.

referencesfeatures-database.md

≈812 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Database

Nitro ships a lightweight SQL layer powered by db0. It defaults to SQLite (.data/db.sqlite) and works out of the box in dev and Node.js production. Experimental — enable the flag.

import { defineConfig } from "nitro";

export default defineConfig({
  experimental: { database: true },
});

Usage

useDatabase() (auto-imported when the flag is on, or import from nitro/database) returns a connection. Optional connection name defaults to "default".

import { defineHandler } from "nitro";
import { useDatabase } from "nitro/database";

export default defineHandler(async () => {
  const db = useDatabase();

  await db.sql`CREATE TABLE IF NOT EXISTS users (
    "id" TEXT PRIMARY KEY, "firstName" TEXT, "lastName" TEXT, "email" TEXT
  )`;

  const id = String(Math.round(Math.random() * 10_000));
  await db.sql`INSERT INTO users VALUES (${id}, 'John', 'Doe', '')`;

  const { rows } = await db.sql`SELECT * FROM users WHERE id = ${id}`;
  return { rows };
});

Connections are created lazily and cached per name.

Query APIs

// Tagged template with safe parameter binding
const { rows } = await db.sql`SELECT * FROM users WHERE id = ${id}`;
const res = await db.sql`INSERT INTO posts (title) VALUES (${"Hello"})`;
// res.rows, res.changes, res.lastInsertRowid

// Raw string execution
await db.exec("CREATE TABLE IF NOT EXISTS t (id TEXT)");

// Prepared statement
const stmt = db.prepare("SELECT * FROM users WHERE id = ?");
const result = await stmt.bind("1001").all();

Always use db.sql tagged templates (or prepare().bind()) for user input — they parameterize and prevent SQL injection.

Configuration

import { defineConfig } from "nitro";

export default defineConfig({
  experimental: { database: true },
  database: {
    default: { connector: "sqlite", options: { name: "db" } },
    users: {
      connector: "postgresql",
      options: { url: "postgresql://user:pass@host:5432/db" },
    },
  },
  // Use a local SQLite db in development while prod uses Postgres
  devDatabase: {
    default: { connector: "sqlite", options: { name: "dev-db" } },
  },
});

Use a named connection with useDatabase("users").

Connectors

All db0 connectors are supported, including: sqlite / node-sqlite, better-sqlite3, bun-sqlite, libsql (+ libsql-http/libsql-web), postgresql, mysql2, pglite, planetscale, cloudflare-d1, and Cloudflare Hyperdrive variants.

Key Points

  • Requires experimental.database: true; defaults to a zero-config SQLite connection.
  • useDatabase() from nitro/database (auto-imported when enabled); names default to "default".
  • Prefer db.sql tagged templates for safe, parameterized queries.
  • Use devDatabase to run a different (local) database in development.
  • Integrates with db0-supported ORMs; prefer this layer over platform-specific DB bindings for portability.
<!-- Source references: - https://nitro.build/docs/database - https://db0.unjs.io -->

Source: SKILL.md on GitHub

No alerts9d3 checks · Risk SAFE
  • Gen Agent Trust Hub9d

    The Nitro skill provides comprehensive documentation for building and deploying web servers using the Nitro framework. It covers routing, configuration, storage, caching, database integration, and deployment presets. The skill is informative and describes standard web framework features and best practices.

  • Socket9d

    No alerts

  • Snyk9d

    Risk: LOW · No issues

Signed by skilld at de09c7b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated last week
Other metadata
metadata
{
  "author": "Anthony Fu",
  "version": "2026.6.22",
  "source": "Generated from https://github.com/nitrojs/nitro, scripts located at https://github.com/antfu/skills"
}

README badge

README badge for onmax/nuxt-skills/nitro