Next.js Discord

Discord Forum

How do you create utility function files with no default export

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
I'm building my app locally and am running into an issue where the compiler complains about a file not having a default export. I managed to solve the issue in one of them by simply adding default

export default ()=>{
//...
}


My nodemailer.ts is completely blank. Do I still need an export default? Do I just do a simple
export default {}

for the compiler to stop complaining? Is this a good work around?

3 Replies

You should only add files that are expected to be pages in the pages directory, everything else should be outside otherwise Next will try to create a routable page to the file
Transvaal lionOP
I thought it would be good practice to place lib folders alongside components, but I guess how NextJS is implemented is to create paths like you mentioned if they're in the pages directory.
that works in app dir, but pages dir every js/ts file is a "routable" page which nextjs tries to use