Back to Medusa

{metadata.title}

www/apps/resources/app/lint/rules/ui-route-must-have-default-export/page.mdx

2.17.01.3 KB
Original Source

export const metadata = { title: ui-route-must-have-default-export - ESLint plugin rules, }

{metadata.title}

This rule requires UI route page files to default-export the React component.

Severity

error. This rule is enabled in the recommended preset.

What it Targets

This rule targets page.tsx files in your project's src/admin/routes directory. It reports a UI route file that doesn't have a default export.

The following code is reported by the rule:

tsx
import { defineRouteConfig } from "@medusajs/admin-sdk"

const CustomPage = () => <>Custom</>

export const config = defineRouteConfig({
  label: "Custom",
})

export { CustomPage }

Instead, default-export the React component:

tsx
import { defineRouteConfig } from "@medusajs/admin-sdk"

const CustomPage = () => <>Custom</>

export const config = defineRouteConfig({
  label: "Custom",
})

export default CustomPage

Why it's Important

Medusa renders the default export of a page.tsx file as the route's page. Without a default export, the route has no component to render.

Learn more in the UI Routes documentation.

Fixable

This rule isn't auto-fixable.