Where to place maxDuration if page.tsx is a client component
Unanswered
Cinnamon posted this in #help-forum
CinnamonOP
If my page.tsx is a client component (rare but it happens), then can I set
I'm also curious if I can declare that variable inside a server action?
Because I can't do this right?
export const maxDuration = 60;
in my layout.tsx file for that same route? I believe so, according to the docs. I'm also curious if I can declare that variable inside a server action?
actions/customer.ts
export async function registerComplexCustomerStuff (customerId: string) {
const maxDuration = 60;
... other function code
}
Because I can't do this right?
actions/customer.ts
const maxDuration = 60; // neither this
export const maxDuration = 60; // nor this are supported, right?
export async function registerComplexCustomerStuff (customerId: string) {
... other function code
}
2 Replies
CinnamonOP
The docs here imply you can use
https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#maxduration
But I get this error when building
export const maxDuration = 5
in a layout.tsx file https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#maxduration
But I get this error when building
Error:
x Only async functions are allowed to be exported in a "use server" file.
1 | 'use server';
2 |
3 | export const maxDuration = 60;
Or maybe you can set maxDuration from a client page.tsx file?