Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Disable" SSR in nextjs

I want to create a Browser-Application without SSR, with React and MUI. So I found a NextJS-Template here:

https://github.com/mui/material-ui/tree/master/examples/nextjs-with-typescript

I want to disable SSR completely, let's say in the best case starting with _document.tsx, but at least the file _app.tsx and all following as for example _index.tsx should be rendered without SSR.

So, how to disable SSR "completely"?

like image 295
tps Avatar asked Sep 15 '25 08:09

tps


1 Answers

While some might tell you to use plain React, others still use Next.js because of things like file-based routing, sane ESLint and TypeScript defaults, and fast compilation times (because of SWC). If you prefer the developer experience of Next.js over standalone React, but don't want/need SSR, then you have the option to use a static HTML export:

next export allows you to export your Next.js application to static HTML, which can be run standalone without the need of a Node.js server. It is recommended to only use next export if you don't need any of the unsupported features requiring a server.

The example template you linked to shouldn't need any additional code changes (running next export on it worked fine for me, it only threw a warning about a missing ESLint configuration which is easy to set up).

like image 109
Mark G Avatar answered Sep 18 '25 10:09

Mark G