Muhammad Kamal
Muhammad Kamal

Reputation: 1459

Nextjs seperate process for frontend and backend

I am using custom server in nextjs. Everytime I make a change in the frontend or backend, nodemon restarts the main process and the child processes. This results in an increased build time.

My expectation is that when I make a change in the pages or other frontend component, the already running server and the database connection should not restart.

How can this be achieved?

I think if I run the custom server seperatly and use rewrites in next.config then I can have the two server running seperatly.

Upvotes: 0

Views: 628

Answers (1)

Andrew Ross
Andrew Ross

Reputation: 1158

GetStaticProps, GetStaticPaths, GetServerSideProps, and GetInitialProps all execute serverside. Actually, unless the component returns JSX it executes on the server. So you have client side and serverside in each pages file, and all serverside in _app and _document. Nextjs has fast refresh so nodemon isn't necessary with Next. Try removing nodemon and just run with yarn next dev or npm run next dev, fast refresh is built in

Upvotes: 1

Related Questions