nextjs - 💡(How to fix) Fix (Await) Redirect causes content collapse (empty state) instead of showing a loader [4 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86860Fetched 2026-04-08 02:08:53
View on GitHub
Comments
4
Participants
3
Timeline
8
Reactions
0
Timeline (top)
commented ×4subscribed ×2issue_type_added ×1labeled ×1

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0
Binaries:
  Node: 20.17.0
  npm: 10.8.2
Relevant Packages:
  next: 15.4.4
  react: 19.1.0
  react-dom: 19.1.0
Next.js Config:
  output: N/A

---

<RedirectionPageClient
        redirectUrl={redirectUrl}
        fallback={<Loading />}
      />

---

'use client';

import { useRouter } from 'next/navigation';
import { ReactNode, useEffect } from 'react';

type RedirectionPageClientProps = {
  redirectUrl: string;
  replace?: boolean;
  fallback: ReactNode;
};
export function RedirectionPageClient({
  redirectUrl,
  replace,
  fallback,
}: RedirectionPageClientProps) {
  const router = useRouter();

  useEffect(() => {
    if (replace) {
      router.replace(redirectUrl);
    } else {
      router.push(redirectUrl);
    }
  }, [redirectUrl, replace, router]);

  return fallback;
}
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/GlebKodrik/redirect

To Reproduce

To Reproduce Start the app with next dev On the page, click the "GO TO CHECK" button You will first see "TEST LOADING..." Then the page content collapses (shows an empty state/blank screen) Finally, the target page content (from gleb) is displayed

Current vs. Expected behavior

Current Behavior After triggering a redirect with redirect from next/navigation, the UI briefly collapses to an empty state before rendering the redirected content. This looks like a freeze or glitch. The issue happens both in development and after running a production build.

Expected Behavior Instead of collapsing to an empty state, the app should keep showing a loader (or any fallback UI) until the redirected page is fully rendered. The transition should feel smooth without a "flash of nothing".

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0
Binaries:
  Node: 20.17.0
  npm: 10.8.2
Relevant Packages:
  next: 15.4.4
  react: 19.1.0
  react-dom: 19.1.0
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Redirects

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

The issue is reproducible locally. I would like to avoid the "collapse" state and instead keep a loader until the redirected page content is ready.

Now, in order for everything to work beautifully, you need to use

<RedirectionPageClient
        redirectUrl={redirectUrl}
        fallback={<Loading />}
      />
'use client';

import { useRouter } from 'next/navigation';
import { ReactNode, useEffect } from 'react';

type RedirectionPageClientProps = {
  redirectUrl: string;
  replace?: boolean;
  fallback: ReactNode;
};
export function RedirectionPageClient({
  redirectUrl,
  replace,
  fallback,
}: RedirectionPageClientProps) {
  const router = useRouter();

  useEffect(() => {
    if (replace) {
      router.replace(redirectUrl);
    } else {
      router.push(redirectUrl);
    }
  }, [redirectUrl, replace, router]);

  return fallback;
}

It needs to be on the server, not the client.

extent analysis

TL;DR

To fix the issue, move the RedirectionPageClient component to the server-side and ensure it returns a fallback UI until the redirect is complete.

Guidance

  • Identify the current location of the RedirectionPageClient component and move it to a server-side component to handle the redirect.
  • Verify that the fallback prop is being used correctly to display a loader or other fallback UI until the redirect is complete.
  • Review the useEffect hook in RedirectionPageClient to ensure it is correctly handling the redirect and not causing any unintended side effects.
  • Test the updated component in both development and production environments to ensure the issue is resolved.

Example

// RedirectionPageServer.js
import { useRouter } from 'next/navigation';
import { ReactNode, useEffect } from 'react';

type RedirectionPageServerProps = {
  redirectUrl: string;
  replace?: boolean;
  fallback: ReactNode;
};

export function RedirectionPageServer({
  redirectUrl,
  replace,
  fallback,
}: RedirectionPageServerProps) {
  const router = useRouter();

  useEffect(() => {
    if (replace) {
      router.replace(redirectUrl);
    } else {
      router.push(redirectUrl);
    }
  }, [redirectUrl, replace, router]);

  return fallback;
}

Notes

The issue seems to be related to the client-side rendering of the RedirectionPageClient component. By moving it to the server-side, we can ensure that the redirect is handled correctly and the fallback UI is displayed until the redirect is complete.

Recommendation

Apply workaround: Move the RedirectionPageClient component to the server-side and use it as RedirectionPageServer to handle the redirect and display a fallback UI until the redirect is complete. This should resolve the issue and provide a smooth transition between pages.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix (Await) Redirect causes content collapse (empty state) instead of showing a loader [4 comments, 3 participants]