9c5bb5bfe9
The `target: serverless` config was deprecated a year ago starting in [Next.js 12](https://nextjs.org/blog/next-12). Tests were disabled in #41252 so we can now remove `target: serverless` and all usage of `target` in `next.config.js`. Co-authored-by: Balázs Orbán <info@balazsorban.com> Co-authored-by: JJ Kasper <jj@jjsweb.site>
1.5 KiB
1.5 KiB
getServerSideProps Export Error
Why This Error Occurred
You attempted to statically export your application via next export
, however, one or more of your pages uses getServerSideProps
.
The getServerSideProps
lifecycle is not compatible with next export
, so you'll need to use next start
when self hosting or deploy to a provider like Vercel.
Possible Ways to Fix It
-
If you'd like to keep your application static, you can use
getStaticProps
instead ofgetServerSideProps
. -
If you want to use server-side rendering, update your build command and remove
next export
. For example, in yourpackage.json
:diff --git a/bla.json b/bla.json index b84aa66c4..149e67565 100644 --- a/bla.json +++ b/bla.json @@ -1,7 +1,7 @@ { "scripts": { "dev": "next dev", - "build": "next build && next export", + "build": "next build", "start": "next start" } }
Note
: Removing
next export
does not mean your entire application is no longer static. Pages that usegetStaticProps
or no lifecycle will still be static!