Skip to content

Docs: async rewrites examples are not async #77598

Open
@masto

Description

@masto

What is the documentation issue?

Per

`rewrites` is an async function that expects to return either an array or an object of arrays (see below) holding objects with `source` and `destination` properties:
and the type definition (
rewrites?: () => Promise<
), rewrites is an async function. The examples, however, neither await anything, nor explicitly return a promise.

JavaScript of course wraps the return value in a promise, so this works, but it may be considered bad form. And some of us have our linters turned up to 11.

Is there any context that might help us understand?

I ran an automated installation script for PostHog, which added this configuration and produced an eslint failure, and that led me to noticing this in the Next.js documentation.

Image

I know that it's trivial to work around and I have done so, but I thought it might be worth considering changing the docs.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/api-reference/config/next-config-js/rewrites

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImprovementReport possible improvements to make in our documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions