{"library":"nitro","title":"Nitro Universal JavaScript Server Builder","description":"Nitro is a robust server engine designed to extend Vite applications with production-ready, universal JavaScript servers that can be deployed across various platforms. Currently, Nitro v3 (`3.0.260415-beta`) is in beta, actively developed with highlights including experimental tracing channels, smarter dependency tracing, and an upgrade to H3 v2, which introduces web standard primitives. The stable version remains v2. Nitro differentiates itself by offering a zero-config experience, automatic file-system based routing for API endpoints, and a focus on performance with compile-time route processing, leading to minimal server bundles. It enables developers to build full-stack applications with capabilities like built-in task runners, scheduled cron jobs, and cross-environment WebSocket support. Releases are frequent, with beta versions seeing rapid iteration and stable versions receiving dependency updates and security fixes.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install nitro"],"cli":{"name":"nitro","version":null}},"imports":["import { defineHandler } from 'nitro'","import { defineNitroConfig } from 'nitro/config'","import { useRuntimeConfig } from 'nitro/runtime-config'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"/* nitro.config.ts */\nimport { defineNitroConfig } from 'nitro/config';\n\nexport default defineNitroConfig({\n  // Customize your Nitro app configuration here\n  runtimeConfig: {\n    // Public keys are exposed to the client-side.\n    // Here, we define a secret key that will be accessible only on the server.\n    apiSecret: process.env.API_SECRET ?? 'default_secret',\n    public: {\n      baseUrl: process.env.PUBLIC_BASE_URL ?? 'http://localhost:3000',\n    },\n  },\n  // Define additional server directories if needed\n  // srcDir: './server',\n});\n\n/* server/api/hello.ts */\nimport { defineHandler } from 'nitro';\nimport { useRuntimeConfig } from 'nitro/runtime-config';\n\nexport default defineHandler(async (event) => {\n  const config = useRuntimeConfig(event);\n  // Access the server-only secret\n  const secret = config.apiSecret;\n  // Access a public config value\n  const baseUrl = config.public.baseUrl;\n\n  return {\n    message: `Hello from Nitro API! Your base URL is ${baseUrl}`,\n    secretRevealed: `Shhh, the secret is: ${secret}`,\n  };\n});\n","lang":"typescript","description":"This quickstart demonstrates how to set up a basic Nitro server with a configuration file, define a simple API route using `defineHandler`, and access both public and private runtime configurations.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}