Skip to content
Discussion options

You must be logged in to vote

AFAIK, they can be anywhere, even library code, as long as Next.js can find the use server directive in the right place. At the top of a file, or inside an async function.

So, the only issue I can ever see, is if this code is in a library, and bundled "incorrectly", for example the entire library code is put into one file such that the use server directive is not in the right place, or if the directive is dropped altogether. I guess one might have to use transpiledPackages or something like that for some library use cases.

As far as placing it as you describe, there should be no problem, within your own project code it should always work.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sabbir-shuvo-ux
Comment options

Answer selected by sabbir-shuvo-ux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants