feat!: admin router adapter#16763
Merged
Merged
Conversation
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
Groups framework adapter implementations under packages/next/src/adapters/ instead of mixing them into elements/ (UI primitives) and utilities/ (misc helpers). The Next adapter is neither — it bridges next/navigation into the RouterAdapterContext contract from payload core. Sets up the structure for the upcoming ServerAdapter to live alongside as adapters/server.ts.
Separates router contracts from cookie contracts: - adapters/router.ts: RouterAdapterComponent, RouterAdapterRouter, LinkAdapterProps - adapters/cookies.ts: CookieStore, CookieOptions - adapters/index.ts: barrel re-export Makes room for ServerAdapter to land as adapters/server.ts on its own branch without re-mingling concerns in a single file.
r1tsuu
approved these changes
May 28, 2026
jacobsfletch
added a commit
that referenced
this pull request
May 29, 2026
Requires #16763 and #16753. Moves all elements and templates defined in the `@payloadcms/next` package to `@payloadcms/ui`. This is in effort to convert the `@payloadcms/next` package into a framework adapter. **Relocated exports** — code physically moved from `@payloadcms/next` to `@payloadcms/ui`: | Component | Old source | New source | | -------------------------- | ----------------------------- | ---------------------- | | `DefaultTemplate` | `@payloadcms/next/templates` | `@payloadcms/ui/rsc` | | `DefaultTemplateProps` | `@payloadcms/next/templates` | `@payloadcms/ui/rsc` | | `MinimalTemplate` | `@payloadcms/next/templates` | `@payloadcms/ui/rsc` | | `MinimalTemplateProps` | `@payloadcms/next/templates` | `@payloadcms/ui/rsc` | | `DocumentHeader` | `@payloadcms/next/rsc` | `@payloadcms/ui/rsc` | | `DefaultNav` | `@payloadcms/next/rsc` | `@payloadcms/ui/rsc` | | `Logo` | `@payloadcms/next/rsc` | `@payloadcms/ui/rsc` | | `HierarchyTypeFieldServer` | `@payloadcms/next/rsc` | `@payloadcms/ui/rsc` | | `DefaultNavClient` | `@payloadcms/next/client` | `@payloadcms/ui` | | `HierarchyTypeField` | `@payloadcms/next/client` | `@payloadcms/ui` | | `NavSidebarToggle` | `@payloadcms/next/client` | `@payloadcms/ui` | | `NavWrapper` | `@payloadcms/next/client` | `@payloadcms/ui` | This PR also removes the now unneeded export aliases. These were in place for backwards compatibility during v3. Now, we enforce that all imports point to its canonical source, not the aliased export. | Component | Old source | New source | | -------------------------- | ------------------------- | --------------------- | | `CollectionCards` | `@payloadcms/next/rsc` | `@payloadcms/ui/rsc` | | `SlugField` | `@payloadcms/next/client` | `@payloadcms/ui` | | `QueryPresetsAccessCell` | `@payloadcms/next/client` | `@payloadcms/ui` | | `QueryPresetsColumnField` | `@payloadcms/next/client` | `@payloadcms/ui` | | `QueryPresetsColumnsCell` | `@payloadcms/next/client` | `@payloadcms/ui` | | `QueryPresetsGroupByCell` | `@payloadcms/next/client` | `@payloadcms/ui` | | `QueryPresetsGroupByField` | `@payloadcms/next/client` | `@payloadcms/ui` | | `QueryPresetsWhereCell` | `@payloadcms/next/client` | `@payloadcms/ui` | | `QueryPresetsWhereField` | `@payloadcms/next/client` | `@payloadcms/ui` | The `./client`, `./rsc`, and `./templates` subpath exports on `@payloadcms/next` are removed entirely. #### Codemod To migrate automatically, there's a codemod for this change available by running: ```bash npx @payloadcms/codemod --transform migrate-next-subpath-exports ```
r1tsuu
added a commit
that referenced
this pull request
Jun 2, 2026
Introduce `@payloadcms/tanstack-start`, a framework adapter that lets the Payload admin run on TanStack Start in addition to Next.js. What's included: - `packages/tanstack-start/` — the adapter package: `RouterAdapter`, `ServerAdapter`, auth server functions, server-function dispatcher, Vite plugins, layouts, and RSC entry points. - `tanstack-app/` — minimal test harness app that boots the adapter for local dev and e2e runs. - `test/adapters/tanstackStartDevServer.ts` — dev-server module the shared test runner will dispatch to when `PAYLOAD_FRAMEWORK=tanstack-start`. - `dev:tanstack` / `test:e2e:tanstack[:headed]` npm scripts and `@payloadcms/tanstack-start` tsconfig path mapping. - Tanstack-specific plan docs under `docs/plans/`. This PR only contains TanStack-specific files. The framework-agnostic abstractions that this adapter consumes (router/server contracts, the move of admin views to `@payloadcms/ui`, `ComponentRenderer`, `renderAdminPage` dispatcher, RSC Flight unification, dev-server test harness abstraction) ship as separate upstream PRs — three of which (#16753, #16763, #16765) are already merged. See `docs/reviews/tanstack-pr-shrink-strategy.md` for the full layering and filing order. The branch will not build standalone until the remaining abstraction- layer PRs land upstream.
r1tsuu
pushed a commit
that referenced
this pull request
Jun 3, 2026
Decouples the root layout from Next.js-specific implementation details. This way we can consume the root layout using alternative React frameworks, e.g. TanStack. The root layout consumes the new [Router Adapter](#16763) and [Server Adapter](#16753), with additional layers of abstraction for font loading and dependency checking. The framework-agnostic implementation lives in `@payloadcms/ui` and is exposed at a new `@payloadcms/ui/layouts` entrypoint. `@payloadcms/next/layouts` continues to work unchanged — it is now a thin wrapper that injects the Next.js adapters, fonts, and dep-check constraints into the ui implementation, so existing app callers need no changes. ```tsx import { RootLayout } from '@payloadcms/ui/layouts' <RootLayout config={config} importMap={importMap} fonts={[{ className: inter.className, variable: inter.variable }]} RouterAdapter={MyRouterAdapter} serverAdapter={myServerAdapter} serverFunction={serverFunction} additionalDependencyChecks={{ dependencyVersions: { 'my-framework': { required: false, version: '>=1.0.0' }, }, }} > {children} </RootLayout> ``` Internally: - `initReq` moves to `@payloadcms/ui/utilities/initReq` and accepts the adapter as an explicit argument rather than reading `next/headers` directly. - Universal `react` / `react-dom` version checks move to `@payloadcms/ui/utilities/checkDependencies`. Each framework adapter layers its own constraints through the `additionalDependencyChecks` prop — the Next.js wrapper passes `next: '>=15.0.0'`. - The Next.js wrapper now lives at `packages/next/src/adapters/layout.tsx`, mirroring the existing `router.tsx` and `server.ts` adapter files. - Language switching now dispatches through the existing `serverFunction` mechanism via a new `switch-language` handler in `@payloadcms/next/utilities/switchLanguageHandler`, rather than as a dedicated `switchLanguageServerAction` prop. The handler writes the cookie using the server adapter via `req.server.setCookie(...)`.
jacobsfletch
added a commit
that referenced
this pull request
Jun 4, 2026
…er (#16884) Removes the `ParamsProvider` and `SearchParamsProvider` from `@payloadcms/ui`, which were deprecated in #9581 since [v3.3.0](https://github.com/payloadcms/payload/releases/tag/v3.3.0). The `useParams` and `useSearchParams` hooks remain available from `@payloadcms/ui` with identical usage — they now originate from the new [Router Adapter](#16763) instead of these dedicated context providers. No migration steps are needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
@payloadcms/uipackage no longer depends onnextdirectly.This PR establishes a pattern to replace the admin panel's router with your own. This way you can power the admin panel with alternative React frameworks than Next.js, e.g. TanStack.
A few key takeaways:
Removes the
nextpackage frompeerDependencieswithin the@payloadcms/uipackage. Does so by providing a new router adapter context that allow for the entire routing layer to be swapped out (see next bullet).Creates a new
RouterAdaptercomponent that abstracts away allnext/navigationusages within the@payloadcms/uipackage. All frameworks will need to supply their own router's methods to the adapter.Here's what the
@payloadcms/nextadapter might look like (simplified):All router methods are now standardized behind shared hooks that can be used within any framework:
Removes all deprecated
Linkprops:import { Button } from '@payloadcms/ui' - import NextLink from 'next/link' export const MyButton = () => { return ( <Button - Link={NextLink} > Click Me </Button> ) }The
Linkcomponent introduced in feat: route transitions #9275 is already router agnostic. Payload has long standardized around this component, which eliminates any need to import fromnext/linkdirectly: