-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore: update migration docs for next/image #5326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: update migration docs for next/image #5326
Conversation
WalkthroughUpdates the React migration guide to replace Next.js patterns with TanStack Start equivalents, including routing, links, loaders, server handlers, dynamic routes, and image handling via Unpic. All changes are confined to a single documentation file’s code examples and text. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Router as TanStack Router
participant Route as Route (createFileRoute)
participant Loader as loader()
participant Component as Page Component
User->>Router: Navigate to "/"
Router->>Route: Match route
alt Loader defined
Router->>Loader: Invoke loader()
Loader-->>Router: Data
Router->>Component: Render with Route.useLoaderData()
else No loader
Router->>Component: Render component
end
sequenceDiagram
autonumber
actor Client
participant Route as /api/hello Route
participant Server as server.handlers.GET
participant Response
Client->>Route: HTTP GET /api/hello
Route->>Server: server.handlers.GET()
Server-->>Response: JSON/text payload
Route-->>Client: 200 OK with body
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/start/framework/react/migrate-from-next-js.md
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
docs/**/*.{md,mdx}
📄 CodeRabbit inference engine (AGENTS.md)
Use internal docs links relative to the docs/ folder (e.g., ./guide/data-loading)
Files:
docs/start/framework/react/migrate-from-next-js.md
docs/{router,start}/**
📄 CodeRabbit inference engine (AGENTS.md)
Place router docs under docs/router/ and start framework docs under docs/start/
Files:
docs/start/framework/react/migrate-from-next-js.md
Next.js uses the `next/image` component for optimized images. In TanStack Start, you can use the package called [Unpic](https://unpic.pics/) for similar functionality | ||
and almost a drop-in replacement. | ||
|
||
```tsx | ||
import Image from "next/image" // [!code --] | ||
import { Image } from "@unpic/react"; // [!code ++] | ||
function Component() { | ||
return ( | ||
<Image | ||
src="/path/to/image.jpg" | ||
alt="Description" | ||
width="600" // [!code --] | ||
height="400" // [!code --] | ||
width={600} // [!code ++] | ||
height={400} // [!code ++] | ||
/> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add install step for Unpic before showing usage.
The new snippet imports @unpic/react
, but we never tell readers to install it. Following the guide as written will crash at build time with “Cannot resolve module '@unpic/react'.” Please insert an install command (e.g. npm install @unpic/react
) in this section before the code sample so the migration instructions are complete.
### Images
Next.js uses the `next/image` component for optimized images. In TanStack Start, you can use the package called [Unpic](https://unpic.pics/) for similar functionality
and almost a drop-in replacement.
+Install the React component:
+
+```sh
+npm install @unpic/react
+```
+
```tsx
import Image from "next/image" // [!code --]
import { Image } from "@unpic/react"; // [!code ++]
🤖 Prompt for AI Agents
In docs/start/framework/react/migrate-from-next-js.md around lines 309 to 326,
the example imports @unpic/react but never tells readers to install it; add an
install step immediately before the code block (e.g., a short sentence and the
npm install @unpic/react command, with equivalent yarn/pnpm examples if you
prefer) so users can install the package before trying the snippet and avoid the
“Cannot resolve module '@unpic/react'” build error.
Summary by CodeRabbit