Next.js Discord

Discord Forum

why hard refresh on redirect from server component?

Unanswered
Rex posted this in #help-forum
Open in Discord
RexOP
I have this root page with the following code
import { createClient } from "@/utils/supabase/server";
import { redirect } from "next/navigation";
import React from "react";

const App = async () => {
  const supabase = createClient();
  const {
    data: { user },
  } = await supabase.auth.getUser();

  if (user) redirect("/home");
  return <div>App</div>;
};

export default App;

I am checking if user present and in case the user is logged in I am just redireing to the home page. If no user presnt then I plan on redirecting to login.
on redirect there is a flicker (basically a hard refresh of the page) why is that and hwo can i fix it?

0 Replies