@wyrly/next
v2.3.1
Published
Request-scoped dependency injection for Next.js App Router and Server Components
Downloads
1,615
Maintainers
Readme
@wyrly/next
Request-scoped dependency injection for Next.js 15+ App Router without reflect-metadata — route
handlers (withDI), Server Actions (withActionDI), and Server Components (createServerDI).
Japanese: README.ja.md
Install
npm install @wyrly/next @wyrly/core next reactPeer dependencies: next ^15.0.0, react ^19.0.0.
Requirements
- Everything required by
@wyrly/core - Next.js 15+ (App Router)
Quick start (Route Handler)
import { withDI } from "@wyrly/next";
import { createContainer } from "@wyrly/core";
const container = createContainer();
export const GET = withDI(container, async (_req, { di }) => {
const usecase = di.resolve(MyUseCase);
return Response.json(await usecase.run());
});For Server Components, use createServerDI — see
API.md.
Documentation
Related packages
| Package | npm | Description |
| ---------------- | -------- | --------------------- |
| @wyrly/core | yes | Core DI |
| @wyrly/next | yes | This package |
| @wyrly/express | yes | Express 5 middleware |
| @wyrly/hono | yes | Hono middleware |
| @wyrly/fastify | yes | Fastify 5 plugin |
| @wyrly/fresh | JSR only | Fresh 2.x |
| @wyrly/graphql | yes | GraphQL request scope |
| @wyrly/yoga | yes | GraphQL Yoga 5 plugin |
| @wyrly/apollo | yes | Apollo Server plugin |
License
Apache-2.0 — see LICENSE.
