Skip to content

Add Nextjs config #85

@thernstig

Description

@thernstig

Vite has its own config. Would it make sense to add one for Next.js? The reason being that Next.js requires this setup:

  {
    plugins: {
      'react-refresh': reactRefresh,
    },
    rules: {
      'react-refresh/only-export-components': [
        'error',
        {
          allowConstantExport: true,
          allowExportNames: ['metadata'],
        },
      ],
    },
  },

Next.js latest version has a convention to export these things:

export const metadata = { ... }
export const dynamic = 'force-dynamic'
export const revalidate = 60
export const runtime = 'edge'
export const fetchCache = 'force-no-store'

I believe that this plugin is necessary and good even for modern Next.js 15 app router projects, at least when I read https://nextjs.org/docs/architecture/fast-refresh#limitations:

The file you're editing might have other exports in addition to a React component.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions