Next.js Discord

Discord Forum

Page router getServerSideProps not working

Unanswered
Pyramid ant posted this in #help-forum
Open in Discord
Pyramid antOP
import Head from "next/head";
import prisma from "@/config/prisma";
import { useEffect } from "react";
import ContactList from "@/components/ContactList/ContactList";
import { GetServerSideProps, InferGetServerSidePropsType } from "next";

type Contact = {
  id: string;
  name: string;
  email: string;
  phone?: string | null;
  subject: string;
  message: string;
  contacted: boolean;
  createdAt: Date;
};


export const getServerSideProps = (async () => {
  const contacts = await prisma.contact.findMany();
  return { props: { contacts } };
}) satisfies GetServerSideProps<{ contacts: Contact[] }>;

export default function Home({
  contacts,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
  console.log(contacts);

  return (
    <>
      <Head>
        <title>Formante+</title>
        <meta
          name="description"
          content="An application for managing the Formante Website"
        />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="icon" href="/favicon.ico" />
      </Head>

      <main>
        <h1>Formante+</h1>
      </main>
    </>
  );
}


Im trying to fect data from my mongodb server using getServerSideProps, and for some rreason i keep getting the error while development
Error: getServerSideProps cannot be used with "output: export". See more info here: https://nextjs.org/docs/advanced-features/static-html-export


When i go to the link it only talk about the build time error and not the run time. Can anyone help me out with this?

1 Reply