You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/migration-guide/v4.mdx
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -151,6 +151,60 @@ Several types and utilities that were re-exported from `@payloadcms/ui` and `@pa
151
151
152
152
Run `npx @payloadcms/codemod --transform migrate-aliased-exports` to migrate automatically. Renamed types are imported using an `as` alias (e.g. `import type { CollectionPreferences as ListPreferences } from 'payload'`) so existing usages keep compiling — drop the alias and rename usages manually if you want to fully commit to the new name.
153
153
154
+
### `next/navigation` and `next/link` replaced by framework-agnostic `RouterAdapter` hooks
155
+
156
+
`@payloadcms/ui` no longer depends on `next` directly. Custom admin components (field components, custom views, plugins) that previously imported router hooks or the `Link` component from `next/*` must now import the framework-agnostic equivalents from `@payloadcms/ui`. Behavior is identical when running on Next.js — the `NextRouterAdapter` shipped by `@payloadcms/next` wires `next/navigation` hooks and `next/link` into the same context — but ui code can now also run on non-Next adapters (e.g. TanStack Start) without modification.
157
+
158
+
**Hooks** — import from `@payloadcms/ui` instead of `next/navigation`:
|`import { useRouter } from 'next/navigation'`|`import { useRouter } from '@payloadcms/ui'`|
163
+
|`import { usePathname } from 'next/navigation'`|`import { usePathname } from '@payloadcms/ui'`|
164
+
|`import { useSearchParams } from 'next/navigation'`|`import { useSearchParams } from '@payloadcms/ui'`|
165
+
|`import { useParams } from 'next/navigation'`|`import { useParams } from '@payloadcms/ui'`|
166
+
167
+
**`Link` component** — use `PayloadLink` from `@payloadcms/ui`:
168
+
169
+
```diff
170
+
- import Link from 'next/link'
171
+
+ import { PayloadLink as Link } from '@payloadcms/ui'
172
+
```
173
+
174
+
**Types** — `LinkProps` from `next/link` is replaced by `LinkAdapterProps` from `payload`:
175
+
176
+
```diff
177
+
- import type { LinkProps } from 'next/link'
178
+
+ import type { LinkAdapterProps } from 'payload'
179
+
```
180
+
181
+
`LinkAdapterProps` is a framework-neutral shape: `href: string`, optional `prefetch` / `replace` / `scroll` / `ref`, plus standard `AnchorHTMLAttributes<HTMLAnchorElement>` (minus `href`). The Next adapter forwards these to `next/link`.
182
+
183
+
**`RouterAdapterRouter` shape** — the object returned by `useRouter()` now has a stable, framework-agnostic surface:
If you were relying on Next-specific extras like `prefetch()` on the router instance, switch to the `Link` component's `prefetch` prop instead.
195
+
196
+
**Custom apps embedding `RootProvider`** — `RootProvider` now requires a `RouterAdapter` prop. Apps using the default Next.js admin layout get this wired automatically. If you assemble `RootProvider` yourself, pass the framework's adapter component:
### `title` and `setDocumentTitle` removed from `useDocumentInfo`
155
209
156
210
For performance reasons, the document title state has been split out of `DocumentInfoContext` into its own `DocumentTitleContext`. Access it through the `useDocumentTitle` hook, which exposes the same `title` and `setDocumentTitle` API. Components that subscribed to `useDocumentInfo` solely for the title will no longer re-render when unrelated document state changes.
0 commit comments