vite-plugin-with-nitro
raw JSON → 0.0.5 verified Mon Apr 27 auth: no javascript
A Vite plugin that adds a Nitro API server to your Vite project, forked from @analogjs/vite-plugin-nitro. Current version 0.0.5 is experimental. Use it to develop and build an API server with Nitro (UnJS) alongside your Vite frontend. Differs from the analogjs fork by being standalone without AnalogJS dependencies. Requires Node >=20 and Vite 5. Release cadence is low; the package is in early stages.
Common errors
error Cannot find module 'vite-plugin-with-nitro' ↓
cause Package not installed or not in node_modules.
fix
Run
pnpm add vite-plugin-with-nitro -S error Error: The plugin 'vite-plugin-with-nitro' requires Node.js >=20.0.0 ↓
cause Node.js version is too low.
fix
Upgrade Node.js to version 20 or higher.
error SyntaxError: Cannot use import statement outside a module ↓
cause The project is not configured as ESM and you are using import syntax.
fix
Add "type": "module" to package.json or rename file to .mjs.
Warnings
breaking Forced Node.js version requirement >=20.0.0 ↓
fix Upgrade Node.js to version 20 or higher.
gotcha The plugin is ESM-only; using require() will fail with a runtime error. ↓
fix Use import syntax or configure your project to use ESM.
gotcha Forked from @analogjs/vite-plugin-nitro; API may differ from the original. ↓
fix Check the documentation for any changes if migrating from the analogjs fork.
deprecated Package is at version 0.0.5 — very early stage, breaking changes may occur. ↓
fix Pin to exact version or expect breaking changes on minor/patch updates.
Install
npm install vite-plugin-with-nitro yarn add vite-plugin-with-nitro pnpm add vite-plugin-with-nitro Imports
- default wrong
const nitro = require('vite-plugin-with-nitro')correctimport nitro from 'vite-plugin-with-nitro' - VitePluginWithNitro
import { VitePluginWithNitro } from 'vite-plugin-with-nitro' - NitroOptions wrong
import { NitroOptions } from 'vite-plugin-with-nitro'correctimport type { NitroOptions } from 'vite-plugin-with-nitro'
Quickstart
// vite.config.ts
import { defineConfig } from 'vite'
import nitro from 'vite-plugin-with-nitro'
export default defineConfig({
plugins: [
nitro({
// Nitro options
preset: 'node-server',
// Optional: customize API directory
apiDir: '.nitro/api',
}),
],
})