Laspeed
Laspeed

Reputation: 1089

How to Fix Pages with `getServerSideProps` can not be exported

I have a Next Js app that has pages with getServerSideProps. I'm now trying to npm run build and npm export it so I can get the 'Out' Folder and host it on firebase but in the process of doing so I get the error pages with "getServerSideProps" can not be exported

getServerSideProps

export async function getServerSideProps(context) {
  const providers = await getProviders();
  const session = await getSession(context);

  return {
    props: {
      providers,
      session,
    },
  };
}

Package.json

 "scripts": {
    "dev": "next dev",
    "build": "next build && next export",
    "start": "next start"
  }

Upvotes: 2

Views: 2867

Answers (1)

Fabio Nettis
Fabio Nettis

Reputation: 2863

I guess you are trying to export your codebase to static HTML / CSS with next export. You can't run this command while any of your pages contain server-rendering logic. Check the official documentation on static exports.

Upvotes: 1

Related Questions