Next.js Discord

Discord Forum

React-query getServerSideProps and Auth

Unanswered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Saltwater CrocodileOP
Hi There, I have a page where users must be signed in in order to request useAllActivitis which is a react-query hook.
I was wondering if it is possible to make the request server side?


import React from "react";
import { useAllActivities } from "@/hooks/activity-hook";
import { GetServerSideProps } from "next";
import { withPageAuthRequired } from "@auth0/nextjs-auth0";
import { ActivityList } from "@/app/components/activities/activitiesList";

export default function ActivitiesPage(props) {

  const { data, isFetched } = useAllActivities()

  return (
    <div>
      <h1>Activiteis IndexPage</h1>
      {isFetched && <ActivityList activities={data!} />}
    </div>
  );
}
export const getServerSideProps: GetServerSideProps = withPageAuthRequired()

0 Replies