Performance: Page.tsx as route definition
This affects the initial page load speed and how quickly the main content appears by defining routes as React Server Components in Next.js.
export default async function Page() { const res = await fetch('https://example.com/api/data'); const data = await res.json(); return <div>{data.content}</div>; }
import React from 'react'; export default function Page() { const [data, setData] = React.useState(null); React.useEffect(() => { fetch('/api/data').then(res => res.json()).then(setData); }, []); if (!data) return <p>Loading...</p>; return <div>{data.content}</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side data fetching in Page.tsx | Many (due to hydration and updates) | Multiple reflows during loading | High paint cost due to delayed content | [X] Bad |
| Server-side async Page.tsx route | Minimal (static HTML) | Single reflow on initial paint | Low paint cost with immediate content | [OK] Good |
Page.tsx file represent?Page.tsx in Next.js App RouterPage.tsx file automatically defines a route based on its folder location.Page.tsx is the React component rendered when visiting that route.Page.tsx?Page.tsx./app/about/Page.tsx exports a component showing <h1>About Us</h1>./about in the browser?/app/about corresponds to the route /about.Page.tsx inside /about exports a component rendering <h1>About Us</h1>.Page.tsx file?export default function Page() {
Welcome
}return keyword, so it returns undefined./dashboard/settings in Next.js App Router. Which folder and file structure correctly defines this route?/app matching the URL path segments./dashboard/settings requires /app/dashboard/settings/Page.tsx with a default export component.Pass the test and this pattern moves unknown