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-tasks.md

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

Tasks

Tasks are one-off runtime operations (migrations, cleanups, cache refresh). Experimental — enable the flag first.

import { defineConfig } from "nitro";

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

Defining tasks

Files in tasks/[name].ts. Nested dirs join with : (e.g. tasks/db/migrate.ts → db:migrate). defineTask is auto-imported.

export default defineTask({
  meta: {
    name: "db:migrate",
    description: "Run database migrations",
  },
  run({ payload, context }) {
    console.log("Running DB migration...");
    return { result: "Success" };
  },
});

run receives a TaskEvent with name, payload (Record<string, unknown>), and context (may include waitUntil). Return { result }.

Tasks can also be registered in config (config handler wins over a scanned file of the same name):

export default defineConfig({
  experimental: { tasks: true },
  tasks: {
    "db:migrate": { handler: "./tasks/custom-migrate.ts", description: "Migrations" },
  },
});

Scheduled tasks (cron)

Map cron expressions to task name(s). Multiple tasks under one expression run in parallel; scheduled runs get a payload.scheduledTime timestamp.

import { defineConfig } from "nitro";

export default defineConfig({
  scheduledTasks: {
    "* * * * *": ["cms:update"],        // every minute
    "0 0 * * *": "db:cleanup",          // daily (string shorthand)
    "*/5 * * * *": ["health:check", "metrics:collect"],
  },
});

Platform support:

  • dev, node_server, node_cluster, node_middleware, bun, deno_server → croner engine.
  • cloudflare_module / cloudflare_pages → native Cron Triggers (wrangler config auto-generated).
  • vercel → native Cron Jobs (config auto-generated; secure with CRON_SECRET).

Running tasks programmatically

import { defineHandler } from "nitro";
import { runTask } from "nitro/task";

export default defineHandler(async (event) => {
  // IMPORTANT: authenticate and validate before running!
  const payload = Object.fromEntries(event.url.searchParams);
  const { result } = await runTask("db:migrate", { payload });
  return { result };
});

runTask throws a 404 if the task doesn't exist, 501 if it has no handler; errors from run propagate to the caller.

Background work with waitUntil

export default defineTask({
  run({ context }) {
    const promise = fetch("https://api.example.com/sync");
    context.waitUntil?.(promise);
    return promise.then(() => ({ result: "ok" }));
  },
});

Dev server tools

While nitro dev runs:

  • GET /_nitro/tasks — list available tasks + scheduled tasks.
  • GET|POST /_nitro/tasks/:name — execute (payload from query and/or JSON body under "payload").
  • CLI: nitro task list and nitro task run db:migrate --payload "{}".

Key Points

  • Requires experimental.tasks: true; defineTask is auto-imported, runTask comes from nitro/task.
  • Each task has one running instance — parallel calls of the same name share a single run/result.
  • scheduledTasks cron config is translated to native triggers on Cloudflare and Vercel automatically.
<!-- Source references: - https://nitro.build/docs/tasks -->

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