Note _document.js vs. _app.js -- What is the difference?
_app.js
: Core of the application, everything is assembled from here at runtime._document.js
: Where side effects are possible.components
: Contains the reusable layouts of the application.context
: Encapsulates a global state that can be accessed from anywhere in the application.hooks
: Encapsulates small pieces of code that represent a certain type of logic.lib
: Chaos property, stores here functionalities that do not have to do with the rest of the mentioned sections.pages/api
: Endpoints for creating an api rest.pages
: pages accessible from the browser via.../page
public
: Static content.styles
: Contains the styles of the application. Override or new styles intailwind.config.js
.nginx
: Contains the nginx server configuration.
Note To change the database you have to modify the
provider
value found in theprisma/schema.prisma
file and the environment variableDATABASE_URL
npx prisma generate
npx prisma db push
Warning If your project does not require a database, you can follow the following actions.
npm uninstall prisma @prisma/client
rm -rf prisma
Warning This version does not include
nginx
redirectión.
Server will be available in:localhost:3000
npm i --force
npm run dev
Warning This version does not include
nginx
redirectión.
Server will be available in:localhost:3000
npm run build
npm run start
Run for a production environment with pm2
Warning This version does not include
nginx
redirectión.
Server will be available in:localhost:3000
pm2 start pm2-deploy.json
docker build --tag next-template-image .
docker build --tag nginx-image ./nginx
docker network create my-network
docker run --network my-network --name next-template-container next-template-image
docker run --network my-network --link next-template-container:nextjs --publish 80:80 nginx-image
Note This version includes
nginx
redirectión.
Server will be available in:localhost:80
docker-compose up -d
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Express.js features
You can check out the NextJS GitHub repository