Package Exports
- @nexpress/next
- @nexpress/next/client
Readme
@nexpress/next
Next.js integration helpers for NexPress —
the Next.js-based CMS. Wires @nexpress/core into a Next.js 15 App Router
site: bootstrap singletons, auth helpers, collection helpers, cache
invalidation.
Despite the name, this package is not the Next.js framework. It's NexPress's integration layer for Next.js apps.
Install
pnpm add @nexpress/nextBootstrap
createBootstrap() is the single factory that wires the DB pool,
storage adapter, plugin loader, and pg-boss producer into the
process-wide singletons:
// src/lib/bootstrap.ts
import { createBootstrap } from "@nexpress/next";
import nexpressConfig from "@/nexpress.config";
import * as generatedSchema from "@/db/generated/collections";
export const { getDb, ensureCoreServices, ensurePluginsLoaded, ensureJobProducer } =
createBootstrap({
config: nexpressConfig,
generatedSchema: generatedSchema as unknown as Record<string, unknown>,
});In your routes, prefer the intent-based wrapper (apps/web/src/lib/init-core.ts
in the reference app):
import { ensureFor } from "@/lib/init-core";
export async function GET() {
await ensureFor("read"); // DB + storage + collections
// ...
}Three intents:
"read"— read-only RSC pages, GET routes"plugins"— render paths that needrunHookto fire"write"— mutating routes / server actions / imports (also wires email + jobs)
Cache invalidation
Use revalidateCollection() instead of importing next/cache directly:
import { revalidateCollection } from "@nexpress/next";
await revalidateCollection("posts");What's also exported
createAuthHelpers()— server-component / route helpers for sessionscreateCollectionHelpers()— typedfindOne/findfor use from RSCtoClientCollectionConfig()— strip server-only bits before passing to a client component
Links
- Repository
- AGENTS.md — architecture overview
- docs/caching.md
- docs/deployment.md
License
MIT