Next.js Discord

Discord Forum

Server component declaration question

Unanswered
Southeastern blueberry bee posted this in #help-forum
Open in Discord
Southeastern blueberry beeOP
I'd like to know if the declaration syntax "export default function Component() {}" is specific to the main component of page.tsx or if I can use it for my static components like my header which is in a separate folder (/component/header.tsx)? Thanks

2 Replies

@Southeastern blueberry bee I'd like to know if the declaration syntax "export default function Component() {}" is specific to the main component of page.tsx or if I can use it for my static components like my header which is in a separate folder (/component/header.tsx)? Thanks
You can declare server components just like normal react components, in other words you can export default, named export or just not export the component at all – they all work
@joulev You can declare server components just like normal react components, in other words you can export default, named export or just not export the component at all – they all work
Southeastern blueberry beeOP
ok I thought exporting directly after a component declaration was specific to the root component of each page thank you