Skip to content

Nuxt

Nuxt uses Nitro as the backend framework for building server-side applications.

To use Nitro as the main provider with Nixle, you need to install the @nixle/nitro package. This package provides the necessary functionality for integrating Nitro into your Nixle application.

Install

You can install the @nixle/nitro package using npm, pnpm, yarn, or bun:

sh
npm i @nixle/nitro
sh
pnpm add @nixle/nitro
sh
yarn add @nixle/nitro
sh
bun i @nixle/nitro

Setup

ts
// server/plugins/nixle.ts
import { createApp, createRouter } from 'nixle';
import { nitroProvider } from '@nixle/nitro';

const usersRouter = createRouter('/users', ({ route }) => [
  route.get('/', () => 'Hello Nuxt!'),
]);

export default defineNitroPlugin((nitroApp) => {
  createApp({
    provider: nitroProvider(nitroApp),
    routers: [usersRouter],
  });
});

Example