Skip to content

Fastify

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

Install

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

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

Setup

ts
import fastify from 'fastify';
import { createApp, createRouter } from 'nixle';
import { fastifyProvider } from '@nixle/fastify';

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

const { app } = createApp({
  provider: fastifyProvider(fastify()),
  routers: [usersRouter],
});

app.listen({ port: 4000 });

Example