There are SSR-related problems with several pages in Next.js project that results in errors on npm run build
and prevent the project from being built:
pages/
foo/
bar/
[id].jsx
index.jsx
index.jsx
...
For example, bar
:
export function getStaticProps() {
return someApiCallThatCurrentlyFails()
...
}
export default function Bar() {...}
As a quick fix, it may be convenient to just not build bar/*.*
pages and make routes unavailable.
Can pages be ignored on Next.js build without physically changing or removing page component files in the project?
Next Js is a React-based framework that provides a developer with everything required for a production-grade application. SSR or Server Side Rendering is also known as dynamic rendering. In SSR the page is generated each time the server gets a request.
NextPage is a type exported by NextJS. When we write Page: NextPage we're saying that our Page component is of type NextPage . Follow this answer to receive notifications.
You can configure the pageExtensions
in the next.config.js
.
// next.config.js
module.exports = {
pageExtensions: ["page.js"],
}
After configuring this, the only pages with *.page.js
will be considered in the below given directory structure.
pages/
├── user
│ └── setting
│ ├── index.js
├── _app.page.js
├── _document.page.js
├── list.page.js
└── theme.ts
Custom file ignores patterns that are not supported yet. You can visit the PR created here, and the solution given here. This is the most satisfactory solution so far.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With