JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 326
  • Score
    100M100P100Q105026F
  • License MIT

Next.js integration helpers for NexPress — bootstrap, auth, collections.

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/next

Bootstrap

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 need runHook to 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 sessions
  • createCollectionHelpers() — typed findOne / find for use from RSC
  • toClientCollectionConfig() — strip server-only bits before passing to a client component

License

MIT