Troubleshooting guides by topic

Next.js, React and TypeScript

Client/server rendering, components, hooks, TypeScript and build errors.

70 English guides in this category

Next.js: cookies().set does not work in Server Component

Trying to set cookies directly when rendering the page returns the cookie limitation error.

Read the solution

Next.js: diagnostics of invalid imports between Client and Server Components

Specific list of causes and tests for import problems Client and Server Components at Next.js — how to identify incompatible imports, sources of errors and corrective steps leading to consistent build and correct behaviour in dev/prod.

Read the solution

Next.js: dynamic subpage works in dev, but production returns 404

Route [slug] in Next.js does not work after build? Check genericStaticParams, dynamicParams and the source of service.

Read the solution

Next.js: Event handlers cannot be passed to Client Component props

An error appears when rendering onClick from Server Component to the client component.

Read the solution

Next.js: global CSS import in wrong component

After adding a new sheet, there is an error regarding the location of the global CSS or the order of styles.

Read the solution

Next.js: How to Debug and Fix Hydration Failed

Hydration failed, server rendered HTML didn't match the client. List of causes and step-by-step checking in Next.js and React.

Read the solution

Next.js: link thumbnail in Messenger or LinkedIn does not change

You replaced Open Graph graphics, but the preview shows the old one. Check metadata, image address, and cache.

Read the solution

Next.js: new article 404 by dynamicParams = false

After adding the article to the data /guides/new returns 404, although older service works.

Read the solution

Next.js: NEXT_REDIRECT Is Caught by try/catch

After calling redirect(), the user stays on the page, and NEXT REDIRECT appears in the log.

Read the solution

Next.js: process.env runs on the server but undefined in the browser

The API variable exists while rendering the server, and in Client Component reads undefined.

Read the solution

Next.js: read headers() blocks static prerendering

The page was previously statically generated, and after adding headers() it switches to dynamic mode or build reports a warning.

Read the solution

Next.js: server-only module accidentally imported in Client Component

Build detects unauthorised import of server-only module into the component from use client.

Read the solution

Next.js: Static Assets Return 404 After Setting basePath

The application in the subdirectory /panel opens HTML, but styles and JavaScript are loaded from invalid paths.

Read the solution

Next.js: two titles and an erroneous canonical after migration to Metadata API

HTML contains a double title or canonical, because part of metadata generates App Router, and part of the old Head component.

Read the solution

Next.js: useSearchParams corrupts static 404 error page

During the next build there is a message about the missing Suspense border on / not-found, although the home page works.

Read the solution

Next.js: window is not defined during SSR component

The application works on customer navigation, but the page refresh ends with a window is not defined error.

Read the solution

React Context: all rows render after changing one field

In CRM, changing a single item of the list re-renders a large number of independent components.

Read the solution

React does not render after changing the object in useState

After adding the item to the array, the list remains unchanged, although the object in the console already has a new item.

Read the solution

React Error Boundary does not catch rejected Promise in click

After an error while saving the Error Boundary form, it does not display a fallback, and the console shows an unhandled booking.

Read the solution

React setState Does Not Increment After Rapid Clicks

Three clicks increases the counter only once, although the carrier has called setState multiple times.

Read the solution

React StrictMode launches effect twice in development

When you open the form in a developer environment you see two identical logs and two queries with effect.

Read the solution

React use callback remembers outdated user rights

After changing the role, the button continues to perform the action according to the previous role saved in callback.

Read the solution

React useMemo returns old results after filter change

Changing the selected category does not update the list until another field is changed.

Read the solution

React: A component is changing an uncontrolled input to be controlled

After downloading the data, the form logs a warning about changing uncontrolled input to controlled.

Read the solution
All English guides
Next.js, React and TypeScript — troubleshooting and solutions