With more recent updates to the NextJS framework, it is now recommended to use getStaticProps or getServerSideProps instead of getInitialProps.
A better practise now then would now be to use getStaticProps and move all API functionality (BD calls) inside of this function.
This would eliviate the need for seperate API routes and all pages would be statically rendered at build time.
Revalidate can be utilised in order to statically regenerate the pages on the fly, so subsequent CRUD operations made against the database create changes within the app without the need to re-build the app everytime changes to data occur.
I built this app to showcase some of the features of the ever-evolving Next JS framework.
It's features include automatic code splitting and the utilisation of Serverless side rendering (the API routes in this application where built using serverless functions).
This app allows the user to perform all CRUD operations against Google Firestore.
Add a movie with the "Add Movie to DB" button, and delete or edit an existing movie after navigating to page of that specific movie.