feat!: admin server adapter#16753
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.
|
149a4c4 to
709d8f4
Compare
Adds server-side adapter passed into server functions (not React context), abstracting framework-specific APIs like cookies, headers, redirect, and forbidden/unauthorized/notFound boundaries. - Define ServerAdapter type and Next.js implementation - Wire ServerAdapter through plugin-multi-tenant entrypoints - Safely access req.server from optional contexts
b9942c4 to
c7cdd4f
Compare
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.
Co-locates the Next ServerAdapter impl with the RouterAdapter impl under packages/next/src/adapters/. Both are framework bridges, not utilities.
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.
…-abstraction Adopts the adapters/ folder split for payload core. Resolves the conflict on admin/adapters.ts by extracting ServerAdapter into adapters/server.ts and updating the two ServerAdapter consumers (config/types.ts, types/index.ts).
r1tsuu
previously approved these changes
May 28, 2026
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(...)`.
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.
Decouples plugins and server components from Next.js APIs, e.g. headers, cookies, server-side navigation, etc. This way we can fully support alternative React frameworks other than Next.js, e.g. TanStack.
This includes:
getCookiesgetHeadersredirectnotFoundThese methods are now accessible behind a new
serverobject. Each framework is responsible for adapting its own methods into this standard format.Before
Before, you'd use direct imports from
next/*:After
After, there are now framework-agnostic methods accessible via
req.server:In custom server components, this is provided to you as a new
serverprop:Writing your own Server Adapter
To write a server adapter, you must provide these methods using your framework's proprietary APIs.
Here's an example of what a Next.js server adapter might look like (simplified):