paramour
Reference@paramour-js/next

@paramour-js/next

Entry points — withTypedRoutes, the router hooks, the devtools seam, and the paramour CLI.

@paramour-js/next is the Next.js integration for paramour: the build-time registry wrapper, client hooks for both routers, and the paramour CLI. The package ships four module entry points plus a binary — import from the entry that matches where the code runs.

. — build-time integration

The main entry exports the Next config wrapper and its supporting types: withTypedRoutes generates and validates the paramour-env.d.ts registry artifact during next dev and next build, with WithTypedRoutesOptions (outFile, strict) controlling where the artifact lives and whether drift fails the build. It also exports ParamourConfig, the type of the paramour.config.ts file the CLI reads, and RouteCollisionError, thrown when two files resolve to one URL. These four are the entry's entire public surface.

./app — App Router hooks

Client hooks for App Router components: useRouteParams, useSearch, and their OrThrow variants, all taking the same route objects you define with defineAppRoute. App-Router params are synchronously available on the client, so results are two-arm SafeResult unions with no loading state. Every hook accepts an optional SelectOptions projection. The module carries "use client" — these are client-component hooks.

./pages — Pages Router hooks

Client hooks for Pages Router components: useRouteParams and useSearch for routes defined with definePagesRoute. They return a three-state RouterResultSafeResult plus a pending arm for the pre-hydration render of statically-optimized pages — and there are deliberately no OrThrow variants. The same SelectOptions bag applies.

./devtools-seam — devtools contract (types only)

A types-only entry: the contract between the observation seam inside the hooks and the @paramour-js/devtools panel that consumes it. You import from it only when building tooling on top of the seam — application code never needs it. The panel itself is documented in the @paramour-js/devtools reference.

The paramour binary

Installing the package puts a paramour CLI on your path with five commands — generate, check, init, list, and doctor — covering artifact generation, CI drift verification, project setup, route inspection, and setup diagnosis. One exit-code contract holds across all of them.

On this page