Next JS has become very popular in last few years, and with release of nextjs 13, Now it has become better and faster in so many ways.
NextJs Pre renders every page by default, so that our application speed improves, as well as reduction in waterfall.
But when you need browser specific libraries, to work like like the
localStorage . it will not work, the build will be failed in production.
You may get this type of error, or window is not defined.
Luckily Disabling SSG its pretty simple.
Just open your page/component and write -
export const dynamic = "force-dynamic";
Now next will not pre render this page, and it will work as intended.
for more information you can visit
Route Segment Config
The Route Segment options allows you configure the behavior of a Page, Layout, or Route Handler by directly exporting…
Thanks !! hope It helps.