Giter VIP home page Giter VIP logo

nextjs-ts's Introduction

NextJS Boilerplate

An opinionated boilerplate to kickstart projects using NextJS

Features

  • ๐Ÿ‘๐Ÿผ Next 12
  • โš›๏ธ React 17
  • ๐ŸŒŠ Custom Document and App
  • โŒจ๏ธ Type safety using TypeScript in strict mode
  • ๐Ÿ’„ Write SCSS & future CSS with PostCSS + preset-env
  • ๐Ÿ–Š SVG sprite for icons
  • ๐Ÿ‘€ Lint your code with ESLint & Stylelint
  • ๐ŸŒˆ Prettier for consistent code style
  • ๐Ÿ”จ Jest + Testing Library for tests
  • โ˜๏ธ Husky + lint-staged for code quality assurance
  • โš™๏ธ Editorconfig file for consistent indents
  • ๐Ÿ—„ Redux with react-redux and redux-thunk

Variation branches

git clone -b custom-server --single-branch [email protected]:sanjaytwisk/nextjs-ts.git
git clone -b enzyme --single-branch [email protected]:sanjaytwisk/nextjs-ts.git
git clone -b no-redux --single-branch [email protected]:sanjaytwisk/nextjs-ts.git

Getting started

Before you can start developing your awesome application you need to install the project's dependencies. Make sure you have Node (>= 10.13.0) and NPM installed and run:

$ npm install

โŒจ๏ธ Development

Once all dependencies have been installed you can start development. To start a development server on http://localhost:3000 run:

$ npm run dev

๐Ÿ–ฅ Production

To run your application in production make sure to run a build first:

$ npm run build

And then start you application with a provided port number (defaults to 3000 if not provided):

$ PORT=8080 npm run start

๐Ÿ–จ Static

You can export your application to a static website as well:

npm run export

This will render static HTML pages into ./out

๐Ÿง Linters

The boilerplate provides a couple of linters to help you keep an eye on code consistency and type safety. There are three linters: one for CSS, one for TypeScript and one for type safety. You can use each of them separately using the following commands:

$ npm run lint:css
$ npm run lint:ts
$ npm run lint:types

TIP: To get the most out of your linters install the corresponding (Stylelint, TSLint) plugins for your editor or IDE

Prettier

Prettier helps you to enforce consistent (opinionated) code style. If possible, you can tell your editor to format you code when you save a file. If you are not able to do this, you can run prettier manually using:

$ npm run prettier

๐Ÿค– Tests

You can write your tests using Jest and Enzyme. You can run all test with the following command

$ npm run test

If you want to follow test driven development you can use:

$ npm run test:dev

Modules

TypeScript

TypeScript and Babel are pre-configured with custom module resolvers. This means you can use absolute imports with custom namespaces by default for the following modules:

/* import common library */
import lib from '@common/<folder>/<lib>'
/* import component */
import Counter from '@components/counter/Counter'
/* import container */
import HomepageCounter from '@containers/counter/HomepageCounter'
/* import store files */
import { CounterAction } from '@store/counter/counterActions'

SCSS

By default the path ./src/common/css is configured as an included path for our scss loader. This means you can import any of this folder's files directly without the relative or absolute path:

@import 'variables';
@import 'colors';

nextjs-ts's People

Contributors

sanjaytwisk avatar dependabot[bot] avatar sobolevn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.