Server page being recognized as a Client component
I have a server component
Here's the error I'm getting which states to not export the
src/app/blog/[slug]/page.tsx
that is being recognized as a client component and I'm not seeing why. It IS rendering a client component <CommentLayout />
but, as I understand, that shouldn't matter. I'm getting an error fetching data from the file system and generating MetaData for the route. Am I going about this in the wrong manner?Here's the error I'm getting which states to not export the
generateMetadata
function but the docs clearly state this is fine.
Functions: generateMetadata
Learn how to add Metadata to your Next.js application for improved search engine optimization (SEO) and web shareability.
12 Replies
Here's the component for reference.
Is the layout a client component?
layout:
No. The layout is server. I'm attempting to migrate my app from the pages to the app router and running into some strange behavior. I may give it another 2-6 months before attempting this again. I'm having issues with the metadata durring build now as well. I don't know what changed but the title was rendering on the browser tab and no longer is. I'm getting this type error
the metadata is all stuctured as above.
What version of next do you have?
"next": "^13.5.5"
maybe try deleting your .next directory and re running dev/build?
is the first file your page? This is what i would do... about/layout and about/page. and root layout would be src/app/layout. and see if that helps
I deleted the .next dir and ran build again, heres the error:
The first file is the page, yes. I'm sorry I dont' follow your suggestion,
"This is what i would do... about/layout and about/page. and root layout would be src/app/layout. and see if that helps"
Can you share a github link to this repo?
yes. heres the branch I'm working on.https://github.com/L-Steinmacher/next-blog/tree/app-router
GitHub
GitHub - L-Steinmacher/next-blog at app-router
making a blog with T3 stack and Next.js. Contribute to L-Steinmacher/next-blog development by creating an account on GitHub.
Okay so change metaData to metadata and don't export your getBlogPosts in app/page and let me know if that works.
do a search all cause you're doing it multiple places.
Holy F***. I feel so dumn, thank you.
i'd also move import Layout from '~/app/pageLayout' from root layout. so create a about/layout and import it there or just combine it all in your root layout app/layout. Just a sugestion tho.
Yeah no problem, I've made plenty of mistakes coding is hard. Feel free t mark my answer as correct 🙂