I'm currently diving into the world of Next.js and Typescript, and I've run into an error that has left me stumped as there doesn't seem to be much information available on it:
"getStaticProps" is not a valid Next.js entry export value.ts(71002)
My aim is to use Prisma to query my database in getStaticProps, retrieve an API key, and pass it as a prop to my page component.
"use client";
import TextSimilarityForm from "@/components/TextSimilarityForm";
import { authOptions } from "@/lib/auth";
import { db } from "@/lib/db";
import { getServerSession } from "next-auth";
import { FC, useState, useRef } from "react";
import { GetStaticProps, GetServerSideProps, NextPage } from "next";
import { ApiKey } from "@prisma/client";
interface apiKeyProps {
apiKey: ApiKey | null;
}
const page = ({ apiKey }: apiKeyProps) => {
return (
<div className="max-w-7xl mx-auto mt-16">
{/* @ts-expect-error Server Component */}
{apiKey && <TextSimilarityForm />}
</div>
);
};
export const getStaticProps: GetStaticProps<apiKeyProps> = async (context) => {
const user = await getServerSession(authOptions);
const apiKey = await db.apiKey.findFirst({
where: {
userId: user?.user.id,
enabled: true,
},
});
return {
props: { apiKey: apiKey },
};
};
export default page;
If anyone could offer some insight into why this error is occurring, I would greatly appreciate it.