iagobruno / nextjs-with-custom-server-boilerplate

A boilerplate of an Express server that renders pages (made with React components) using NextJS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nextjs-with-custom-server-boilerplate

A boilerplate of an Express server that renders pages (made with React components) using NextJS.

I made this project for future personal use but if you want you can use it too. πŸ‘

Packages and tools used

Installation

git clone https://github.com/iagobruno/nextjs-with-custom-server-boilerplate.git
cd nextjs-with-custom-server-boilerplate
yarn install

CLI commands

  • yarn run start:dev: Start server in development mode on port 3000 using ts-node-dev. It will restart if you make changes to any file.
    • You can use --api-only argument to prevent starting nextjs.
  • yarn run start:debug: Same as the above command but optimized to be attached by VS Code debugger.
  • yarn run build: Compile server and client codes into a production optimized version.
  • yarn run start: Start server in production mode. Requires the "build" command to be executed first!

Folder structure

.
β”œβ”€β”€ .vscode
β”œβ”€β”€ client  // Contains all client-side codes.
β”‚   β”œβ”€β”€ components  // Folder with React components.
β”‚   β”œβ”€β”€ pages  // Folder with Next's Page components.
β”‚   β”œβ”€β”€ next.config.js  // Self explanatory.
β”‚   └── tsconfig.json  // TypeScript compiler options specific to client codes.
β”œβ”€β”€ common  // Contain files that are used in many parts of the project.
β”œβ”€β”€ dist  // Folder where compiled server code will be placed by the "build" script.
β”œβ”€β”€ public  // Contains static files to be publicly served by Express.
β”œβ”€β”€ server
β”‚   β”œβ”€β”€ main.ts  // Config express server.
β”‚   β”œβ”€β”€ next.ts  // Init NextJS.
β”‚   └── start.ts  // Start express server.
β”œβ”€β”€ globals.d.ts
β”œβ”€β”€ tsconfig.json  // Main Typescript compiler options
β”œβ”€β”€ package.json
└── yarn.lock

About

A boilerplate of an Express server that renders pages (made with React components) using NextJS.


Languages

Language:TypeScript 86.8%Language:JavaScript 7.3%Language:CSS 6.0%