Next.js Discord

Discord Forum

getServerSideProps undefined not working

Answered
Spectacled bear posted this in #help-forum
Open in Discord
Avatar
Spectacled bearOP
I have a component setup with a getServerSideProps and for some reason I got undefined for the initialUserData.

code:
export async function getServerSideProps(context: any) {
  // Fetch user data from Supabase using session

  return {
    props: {
      initialUserData: "something",
    },
  };
}

function DashboardWrapper({ children, initialUserData }: any) {
  const router = useRouter();
  const [loading, setLoading] = useState(false);
  const [stage, setStage] = useState("");
  const [paymentModal, setPaymentModal] = useState(false);
  const [type, setType] = useState("");
  const [success, setSuccess] = useState(false);
  const supabase = useSupabaseClient();
  const [complete, setComplete] = useState(false);
  const [discordModal, setDiscordModal] = useState(false);
  const [userData, setUserData] = useState<any>({});

  useEffect(() => {
    console.log("initialUserData", initialUserData);
  }, [initialUserData]);
Image
Answered by Asian black bear
gSSP only exists for pages, not components
View full answer

5 Replies

Avatar
Asian black bear
gSSP only exists for pages, not components
Answer
Avatar
Spectacled bearOP
Ohh
Is there any alternative solution?
Avatar
Asian black bear
Pass data down from the page
Avatar
Spectacled bearOP
Okay