网页 综合 更新时间 2026-11-13 17:03:39

Quick Start - Nitro

自动蜘蛛 nitro.build 正文约 1552 字
Quick Start - Nitro
Start with a fresh Nitro project or adopt it in your current Vite project.
Get a taste of Nitro in your browser using our playground.
Play with Nitro in StackBlitz
The fastest way to create a Nitro application is with the nitro create command.
Make sure you have the latest LTS version of Node.js or Bun installed.
The --min-release-age=0 (npm) and --config.minimum-release-age=0 (pnpm) flags skip any minimum release age you have configured, so you always get the latest Nitro release.
Follow the CLI instructions and you will be ready to start your development server. See nitro create for all options.
You can add Nitro to any existing Vite project to get API routes, server-side rendering, and more.
Add the Nitro plugin to your vite.config.ts:
Create a nitro.config.ts to configure the server directory:
The serverDir option tells Nitro where to look for your server routes. In this example, all routes will be inside the server/ directory. By default serverDir is false, so no directories are scanned until you set it (or scanDirs).
Create your first API route at server/api/test.ts:
The file path maps directly to the route URL: server/api/test.ts becomes /api/test. Handlers can return strings, JSON objects, Response instances, or readable streams.
As an alternative to filesystem routing, you can declare routes programmatically using the routes config option. See Programmatic route handlers for more details.
Your API route is now accessible at http://localhost:3000/api/test :sparkles:
Nitro builds full-stack servers that deploy anywhere.
访问原文 返回搜索 https://nitro.build/docs/quick-start
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。