Skip to main content

`getServerSideProps` Export Error

Why This Error Occurred​

You attempted to statically export your application via output: 'export' or next export, however, one or more of your pages uses getServerSideProps.

It is not possible to use getServerSideProps without a server, so you'll need to use next start when self hosting or deploy to a provider like Vercel.

Possible Ways to Fix It​

  1. If you'd like to keep your application static, you can use getStaticProps instead of getServerSideProps.

  2. If you want to use server-side rendering, update your build command and remove output: 'export' and remove next export. For example, in your package.json:

    --- a/package.json
    +++ b/package.json
    @@ -1,7 +1,7 @@
    {
    "scripts": {
    "dev": "next dev",
    - "build": "next build && next export",
    + "build": "next build",
    "start": "next start"
    }
    }
    --- a/next.config.js
    +++ b/next.config.js
    @@ -1,4 +1,4 @@
    {
    module.exports = {
    reactStrictMode: true,
    - output: "export",
    }
    }

Note: Removing export does not mean your entire application is no longer static. Pages that use getStaticProps or no lifecycle will still be static!