Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

The default export is not a React Component in page

A page module resolved its default export to an object or a promise. Check the export shape, barrel files, async client components and HOC wrappers.

~5 min readNext.js
#Next.js#React#App Router#Debugging
A page module crate whose default export slot holds an object instead of a component, marked by an amber warning plate

Introduction & Quick Summary

text
Error: The default export is not a React Component in page: "/dashboard"

Next.js rendered a route, imported its module, read default, and found something that is not a component: undefined, a plain object, a string, a number, or a promise. The route was matched correctly, so the error is not about routing. It is about what the module exports.

The five causes, in the order they actually happen:

  • The export is missing or renamed. export function Page() without default, or export default page where the identifier does not exist, leaves default undefined.
  • export default points at a config object. A Next.js metadata object, a typed routes constant, or a dynamic config exported as default instead of named, is not callable.
  • An async client component. In the App Router an async function marked "use client" resolves to a promise, which is not a valid component type.
  • A barrel file re-exports the wrong binding. export { default } from "./Dashboard" fails when Dashboard.tsx exports only named components.
  • A wrapper returned a value instead of a component. export default withAuth(Dashboard) where withAuth calls the component immediately rather than returning a function.
Message variantMeaningTypical fix
default export is not a React Component in pagedefault is not function/class/forwardRefExport a component as default
The default export is not a React Component in page: "/"Same, with route in App RouterCheck the page file for that route
Element type is invalid: expected a string ... but got: objectRuntime equivalent in ReactLook for a bad re-export
Type error: Page ... does not match the required typesType layer catching the same bugAlign the export signature
Build passes, runtime failsComponent resolved through a dynamic importCheck the import path and default interop

Core Mechanics, Signatures & Reproducible Setup

A page module contract is narrow. In the App Router, page.tsx must default-export a function or class that React can instantiate, optionally accepting params and searchParams props (both promises in Next.js 15 and later). In the Pages Router, pages/*.tsx must default-export a component, and named exports such as getServerSideProps are read separately.

A minimal reproduction is one file that exports an object:

tsx
// app/dashboard/page.tsx const config = { title: "Dashboard" }; export default config;
bash
next dev # Error: The default export is not a React Component in page: "/dashboard"

The fix is to export a component and move the data to metadata:

tsx
// app/dashboard/page.tsx import type { Metadata } from "next"; export const metadata: Metadata = { title: "Dashboard" }; export default function DashboardPage() { return <main>Dashboard</main>; }

An async client component reproduces the same failure in a subtler way:

tsx
"use client"; export default async function Page() { const res = await fetch("/api/me"); return <div>{res.status}</div>; }
text
Error: The default export is not a React Component in page: "/account"

Keep the client component synchronous and fetch in an effect, or move the await into a server component and pass data down:

tsx
// app/account/page.tsx (server component, no "use client") import AccountView from "./AccountView"; export default async function Page() { const res = await fetch("https://api.example.com/me", { cache: "no-store" }); const user = await res.json(); return <AccountView user={user} />; }

The fastest way to see what is actually exported is a one-line probe in the module:

ts
console.log(typeof (await import("./app/dashboard/page")).default);

Key Comparison Table

Export shapeValid page default?What Next.js seesOutcome
export default function Page() {}YesFunctionRenders
export default class Page extends React.ComponentYesClassRenders
export default async function Page() (server)YesAsync functionRenders
export default async function Page() with "use client"NoPromise when calledThis error
export default { title }NoObjectThis error
export function Page()Nodefault undefinedThis error
export default memo(Page)YesObject with $$typeofRenders
RouterFile conventionExtra requirement
App Routerapp/**/page.tsxProps are promises from Next.js 15
Pages Routerpages/**/*.tsxNo App Router directives allowed
Layoutapp/**/layout.tsxMust accept and render children
Route handlerapp/**/route.tsMust export HTTP verbs, not a component
Error boundaryerror.tsxMust be a client component

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

Case 1: A route file that should be a handler

Putting component code in route.ts produces the mirror-image error, and putting handler code in page.tsx produces this one.

ts
// app/api/health/route.ts export async function GET() { return Response.json({ ok: true }); }

If the file is named page.tsx it must return JSX, so keep handler and page files separate.

Case 2: Default and named mixed up in a barrel

tsx
// components/index.ts export { Dashboard } from "./Dashboard"; // named only
tsx
// app/dashboard/page.tsx export { default } from "@/components"; // no default exists

Re-export the exact binding or import the named component and export it:

tsx
import { Dashboard } from "@/components"; export default Dashboard;

Case 3: An HOC that calls instead of wraps

tsx
// broken const withAuth = (Component) => Component(); // correct const withAuth = (Component) => { function Wrapped(props) { return <Component {...props} />; } return Wrapped; };

A HOC that invokes the component returns its output, which may be a promise or an element, neither of which is a component type.

Case 4: Interop with a CommonJS package

tsx
import Chart from "legacy-chart"; // module.exports = { default: ... }

Depending on the bundler and esModuleInterop, default can land on .default.default. Check what the module really exposes:

bash
node -e "const m=require('legacy-chart'); console.log(Object.keys(m), typeof m)"

Normalize at the edge with a small adapter rather than changing compiler flags for the whole app.

Case 5: A dynamic import returning the namespace

tsx
const Page = dynamic(() => import("./Page")); // fine: dynamic unwraps default const Page = dynamic(() => import("./Page").then((m) => m)); // namespace object

Returning the whole namespace gives Next.js an object, so return m.default explicitly when the module has no default export helper.

Case 6: params typed as a plain object in Next.js 15+

The error message changed shape but the class of failure is the same: the module's contract no longer matches. Await the props:

tsx
export default async function Page({ params }: { params: Promise<{ id: string }> }) { const { id } = await params; return <div>{id}</div>; }

Common Compilation/Runtime Mistakes & Version Gotchas

  • export default on an arrow with a type assertion. export default (() => null) as unknown as SomeType can erase the callable type at build time and still resolve to a non-component at runtime. Prefer plain function declarations for pages.
  • Fast Refresh hiding it. Editing a page can leave a stale module in the dev server when the export changes shape. Restart next dev before debugging further; a rebuild that suddenly works is evidence of staleness.
  • Server Actions and pages in one file. A file with "use server" at the top cannot also default-export a component. Split them.
  • next/dynamic with ssr: false inside a server component. Next.js 15 rejects this combination, and the error surfaces near the same import path. Move the dynamic import into a client component.
  • Typed routes. With typedRoutes enabled, a wrong default export can surface as a type error before runtime, which is the cheaper place to catch it. Run next build locally, not only next dev.
  • Cache amnesia. A deployed page that fails only in production often has a build-time output: "export" mismatch; check that the route is not statically exported without a component.

When the failing file is minified or the stack is unreadable, paste the bundle fragment into the JSON formatter only to inspect embedded source maps, and use the diff tool to compare a working page against the broken one line by line. If the error arrives as an HTTP 500 response from a server you do not control, the status code reference tells you whether the gateway or the app is at fault.

Primary references: the Next.js page file convention defines the props and export contract, and the React element type validation notes explain the runtime check behind the equivalent React error.

Official references

primary documentation

The Next.js documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Next.js work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Next.js guides

More in Next.js

All Next.js guides

The guides filed next to this one in Next.js, in library order.