Reputation: 1
When I navigate from one page to another in Next.js, my page content--such as images, text, and style padding--doesn't render properly. However, when I refresh the page or copy the link and open it directly in a new tab, everything displays correctly. This problem only occurs when I go through routes in Next.js. I think the assets are not loading properly when switching routes.
Upvotes: 0
Views: 149
Reputation: 1
Use Next.js Link Component: Ensure that you're using Next.js' Link component for client-side navigation instead of regular anchor tags (). Next.js' Link component prefetches assets for the linked page, which can help ensure that assets are loaded properly when navigating between routes.
Example
import Link from 'next/link';
<Link href="/other-page">
<a>Go to Other Page</a>
</Link>
Upvotes: 0