/nextjs-compare-lab

Lab intended to compare nextjs with create react app.

Primary LanguageTypeScript

Next JS lab

Compare NextJS to Create React App.

Evaluation criteria

  • Initial setup
  • Configuration / Customization
  • Routing / Pages
  • Dev workflow
    • TypeScript
  • Production build output
  • CSS handling
  • Asset handling

Client side rendering (CSR) / Server side rendering (SSR) / Static site generation (SSG).

Create React App (CRA)

Command history

# Check the options
npx create-react-app --help

# Create new app from typescript template
npx create-react-app --template typescript cra-example-typescript # `--template typescript` == `--template cra-template-typescript`

# Start dev
cd cra-example-typescript
PORT=4000 npm start
# Build production bundle
npm run build

# Any static file server will work
serve build -p 4001 # Requires `serve` to be installed (`npm install -g serve`)

cra-network

Result

  • Without ejecting the project is fairly clean 👍

Dev workflow with all defaults.

Production bundle.

  • Client side rendering 🤷
    • Empty html initially.
    • ... routing ...

NextJS

Some links.

Command history

# Check the options
npx create-next-app@latest --help

# Create new app with typescript
npx create-next-app@latest --typescript # No <project-name> given, will be interactive

# Start dev
cd next-example-typescript
npm run dev
# Build production bundle
npm run build

# Server included, can be required
npm run start -- -p 5001

next-network

Result

Dev workflow with all defaults.

  • Live reload css works 👍
  • Live reload react component works 👍
  • No tests at all by default 👎
  • Importing .svg files "just work" 👍
  • .css can be imported 👍
  • .module.css works as expected 👍
  • No builtin storybook support 😕
  • File based routing 🤯

Production bundle.

  • Static site generation by default 🏎
    • Rendered html initially ⭐️
    • File based routing 🤯

Third party library.

  • "Just works" 👍 (have only tested ReactQuery)