The `nestjs-better-auth-fastify` package provides a dedicated NestJS module for integrating authentication capabilities specifically when using the Fastify platform adapter. It acts as a bridge, leveraging the underlying `better-auth` library to deliver authentication services tailored for high-performance Fastify-based NestJS applications. Currently, the package is in early development, reflected by its 0.0.24 version, which implies that API surfaces may change without adhering to strict semantic versioning, although recent releases show largely minor updates. Its core differentiator lies in its optimized integration with Fastify, providing a specialized solution for developers prioritizing Fastify's performance benefits within the NestJS ecosystem, rather than a generic authentication module. While recent changes have been minimal, early versions typically address fundamental architectural considerations and bug fixes, such as making `@nestjs/graphql` an optional dependency.
npm install nestjs-better-auth-fastifyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up a basic NestJS application using Fastify as the platform adapter and integrating `nestjs-better-auth-fastify` with a minimal configuration.
Always pin to exact versions (e.g., `"nestjs-better-auth-fastify": "0.0.24"`) or use caret ranges with caution. Thoroughly test updates in development environments.
Ensure you are using `v0.0.17` or newer if you wish to use the module without installing `@nestjs/graphql`. If on an older version and not using GraphQL, consider installing `@nestjs/graphql` as a temporary workaround or upgrade.
Ensure your `main.ts` or `main.js` explicitly configures the NestJS application to use `new FastifyAdapter()` when calling `NestFactory.create()`.
Verify `better-auth` is listed in your `package.json` and installed. Check the `forRoot` configuration for any missing required properties or incorrect types as per `better-auth`'s documentation.
Ensure `NestFactory.create` is explicitly typed and instantiated with `new FastifyAdapter()`. Example: `await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter());`