zeon-studio / nextplate

Nextplate is a free starter template built with Next.js and TailwindCSS. It provides you with almost everything you need to jump-start your Next.js project. Try Nextplate and save yourself hours of work.
https://zeon.studio/preview?project=nextplate
MIT License
413 stars 252 forks source link

Issue with useRouter in Custom Next.js Project Structure (Nextplate Template) #22

Closed oyfin closed 10 months ago

oyfin commented 10 months ago

I'm using the Nextplate template for my Next.js project, which has a unique structure with pages located in src/app instead of the standard pages directory. I'm encountering an issue with useRouter, specifically receiving the error: "NextRouter was not mounted".

Could you provide guidance on how to correctly use useRouter or an alternative method for dynamic routing and data fetching in this non-standard setup? Any insights or documentation specific to handling routes and data fetching in the Nextplate template would be greatly appreciated.

Thank you!

tffaruk commented 10 months ago

Hey @oyfin When using the App Router, the useRouter hook should be imported from next/navigation instead of next/router. Thank you for using our Nextplate. To learn more please visit: https://nextjs.org/docs/app/api-reference/functions/use-router