TypeScript

Nitro is TypeScript-first: write your config, handlers, and server code in TypeScript with zero setup.

Nitro is written in TypeScript and bundles your server code, so .ts files work out of the box in development and production, with no separate compile step. The TypeScript compiler is only needed for type checking (for example tsc --noEmit in CI).

All public utilities ship with types:

import { defineConfig } from "nitro";

export default defineConfig({
  // Fully typed config with completions
});

Types (such as NitroConfig, NitroModule, or NitroRuntimeConfig) are exported from nitro/types:

import type { NitroModule } from "nitro/types";

#tsconfig.json setup

Nitro provides a shareable TypeScript configuration you can extend from:

tsconfig.json
{
  "extends": "nitro/tsconfig"
}

It enables modern, strict defaults matching how Nitro bundles your code: strict type checking, bundler module resolution, noEmit, verbatimModuleSyntax, and allowImportingTsExtensions (so you can use explicit .ts extensions in imports). You can override any option by adding your own compilerOptions on top:

tsconfig.json
{
  "extends": "nitro/tsconfig",
  "compilerOptions": {
    "jsx": "react-jsx"
  }
}

#typescript config options

OptionDefaultDescription
tsConfigProject tsconfig.jsonTypeScript config used by the bundler for JSX options and path aliases.
tsconfigPathstrueResolve path aliases (compilerOptions.paths) of tsConfig for the server sources.

Nitro reads your project's root tsconfig.json to pick up JSX settings (jsx, jsxFactory, jsxFragmentFactory, jsxImportSource) and path aliases (compilerOptions.paths). Set typescript.tsConfig to override it:

nitro.config.ts
import { defineConfig } from "nitro";

export default defineConfig({
  typescript: {
    tsConfig: {
      compilerOptions: {
        jsx: "react-jsx",
      },
    },
  },
});

#Path aliases

Path aliases (compilerOptions.paths) are resolved for your server sources with every builder and with builder: false, including those inherited with extends.

  • The alias option (and Vite's resolve.alias) takes precedence over path aliases.
  • Paths to declaration files (.d.ts) are ignored, the import keeps its regular resolution.
  • With the Vite builder, they apply to the Nitro environment only. Enable Vite's resolve.tsconfigPaths option for the other environments. In development, patterns starting with * do not apply to installed packages.
  • Set typescript.tsconfigPaths: false to disable them.

Nitro  builds full-stack servers that deploy anywhere.