How to Setup Next.js + TypeScript + Eslint + Storybook + Jest + Enzyme

How to Setup Next.js + TypeScript + Eslint + Storybook + Jest + Enzyme

Setting up the developer tools for serious React developers

We’ll skip the introductory BS and get straight into this guide. You can see the finished project in this Github repo. If you check the commit history, I’ve created commits for each “step” of this process.

Technologies

  • Next.js — SSR React
  • Eslint — Code style/formatting
  • TypeScript — Typed version of JavaScript
  • Jest — Component testing Library
  • Enzyme — Testing utility for Jest
  • Storybook — Component building tool

Setup Next.js and TypeScript

First, we’ll start by creating a new Next.js project with TypeScript. Open up your terminal and run:

yarn create next-app

Follow any prompts this tool gives you, and you should have an initialized Next.js project!

Next, create a tsconfig.json file with the following command:

touch tsconfig.json

Install some TypeScript dependencies:

yarn add --dev typescript @types/react @types/node

Then start the Next.js app with yarn dev to automatically fill out the tsconfig.json .

We’ll convert index.js to index.tsx and convert our HomePage component to a lambda function, then add a proper type:

const Home: React.FC = () => {
  // The rest of the component
  // ...
}
export default Home;

Awesome, now we have TypeScript and Next.js playing well together! The next step is setting up eslint.

react javascript nextjs

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Increase Performance of React Applications Via Array JavaScript Methods

Increase Performance of React Applications Via Array JavaScript Methods. We will create a simple event management application in the react to add, update, and delete an event.

Top VSCode Extensions for React, React Native, JavaScript and Productivity

Bunch of VSCode Extensions that improve quality of your coding time no matter what stack you are using. In this post, you'll see Top VSCode Extensions for React, React Native, JavaScript and Productivity

Qual a relação entre Java e JavaScript, C e C++, React e React Native

Qual a relação entre Java e JavaScript, C e C++, React e React Native

Routing in React without React-Router

I have been using React JS in my projects for quite some time now and am used to managing routing in my app using the react-router package. I have always been keen on having as little dependencies in my apps as possible, so, I always felt perturbed by the use of this particular package in simpler apps which did not have complex routes.