#export const maxDuration

1 messages · Page 1 of 1 (latest)

surreal pasture
#

Can I use this on a page.tsx?

agile stoneBOT
#

Hi @surreal pasture. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, you can use export const maxDuration in a page.tsx file in Next.js. This setting allows you to specify the maximum duration for the execution of server-side logic on a specific page.

Here is an example of how you can use it:

export const maxDuration = 5

export default function MyPage() {
  // page content
}

In this example, the server-side logic for MyPage is limited to run for a maximum of 5 seconds.

Please note that this setting requires Next.js version 13.4.10 or higher. Also, if you're using Server Actions (https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations), setting the maxDuration at the page level will change the default timeout of all Server Actions used on the page.

However, there was a known issue where maxDuration was not recognized as a valid Next.js entry export value, causing a TypeScript error. This issue has been fixed in the latest Next.js canary release and should be available in the stable version soon.

Sources:


Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@surreal pasture kapa.ai is still learning and improving, please let us know how it did by reacting below

surreal pasture
#

@agile stone how to fix "maxDuration" is not a valid Next.js entry export value.

agile stoneBOT
#

Let me check the knowledge base for you. One moment! :books:

#

The error message "maxDuration is not a valid Next.js entry export value" was a known issue in Next.js. This issue has been fixed in the latest Next.js canary release.

To resolve this issue, you can update your Next.js to the latest canary version. You can do this by running the following command in your terminal:

npm install next@canary

Or, if you're using yarn:

yarn add next@canary

After updating, the maxDuration export should be recognized correctly by Next.js.

Please note that this fix should also be available in the stable version of Next.js soon. If you prefer to use stable versions, you can wait for the next stable release.

Source: Github Issue (https://github.com/vercel/next.js/issues/59753)

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: