SShortSingh.
Back to feed

How to Convert Slow Next.js Routes to Instant Navigations with Cache Components

0
·1 views

Next.js Instant Navigations allow web apps to commit an App Shell immediately on user click, while slower or personalized content streams in via Suspense boundaries. Developers can enable this feature route-by-route by turning on the experimental cacheComponents flag in next.config.js, minimizing deployment risk and making performance gains easier to measure. Functions performing expensive data fetches should be marked with 'use cache', while runtime-only reads such as cookies or headers must be placed inside Suspense children to keep the shell deterministic. For session-driven UI, the 'use cache: private' directive combined with runtime prefetching allows personalized widgets to also benefit from instant navigation. The approach targets high-traffic routes like search pages and dashboards, where even a single converted route can deliver measurable improvements in user experience and Core Web Vitals scores.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

OGAM App Lets Users Practice Foreign Languages Offline Using On-Device AI

A mobile app called OGAM (Off Grid AI Mobile) allows users to practice speaking foreign languages without an internet connection by converting speech to text and generating replies through a local AI model. The app is available for Android 10 or later devices with at least 4 GB of RAM, and for iPhones from the iPhone 12 onward running iOS 17 or later. Users select a multilingual on-device transcription model and a local text model that supports their target language, then set up role-based practice scenarios such as ordering food or checking into a hotel. A paid Pro version adds text-to-speech functionality, with downloaded voice support currently available for eight languages including Spanish, French, German, and Hindi. All models and assets must be downloaded while connected to the internet before offline use can begin.

0
ProgrammingDEV Community ·

Developer Makes First Open-Source Contribution by Removing Leftover Console.log

A developer made their first open-source contribution to DevLinks, a project maintained by the Kalvium community, by resolving Issue #19, which involved removing a leftover console.log statement. Before making any changes, the contributor took time to understand the repository's structure, using AI as a learning aid while manually verifying the relevant code themselves. The fix was submitted on a dedicated branch and merged via PR #33. The experience highlighted that open-source contribution involves more than writing code — it requires navigating unfamiliar codebases and following established project workflows. The developer plans to tackle more complex issues in future contributions.

0
ProgrammingDEV Community ·

OGAM App Lets Users Draft Emails and Documents Offline Using Voice Input

A mobile app called OGAM (Off Grid AI Mobile) allows users to convert spoken ideas into written drafts entirely offline, without relying on cloud services. The app first transcribes speech into editable text using an on-device speech recognition model, then uses a locally downloaded language model to shape that text into emails, outlines, or proposals. Both models must be downloaded during an initial setup while connected to the internet, after which all processing runs on the device. The workflow requires Android 10 or later with at least 4 GB of RAM, or an iPhone 12 or newer running iOS 17 or later. Users are advised to review and correct transcripts before sending them to the text model, and to instruct the model to flag any missing information rather than invent details.

0
ProgrammingDEV Community ·

React 19 useFormStatus Fix: How to Handle Pending State and Multi-Button Forms

React 19's useFormStatus hook silently returns false when called in the wrong component, since it only tracks a parent form rather than one rendered by the same component. A developer built a reusable SubmitButton component to address this, replacing the native disabled attribute with aria-disabled to prevent focus loss for keyboard users during form submission. A second issue emerged in forms with multiple submit buttons, where the pending state applied to the entire form rather than the specific button clicked, causing all buttons to appear active simultaneously. To resolve this, the solution reads the submitted button's intent from FormData and compares it to each button's identifier, ensuring only the pressed button shows a pending state. The developer also recommends wrapping form fields in a fieldset component that auto-disables inputs during submission, reducing the need for individual disabled props on each field.

How to Convert Slow Next.js Routes to Instant Navigations with Cache Components · ShortSingh