DEV Community

Cover image for Setup Next.js 14 project with Eslint + Prettier + Tailwind CSS
JSDev Space
JSDev Space

Posted on

51

Setup Next.js 14 project with Eslint + Prettier + Tailwind CSS

To set up a Next.js 13 project with ESLint and Prettier, you can follow these steps:

Step 1: Create a Next.js Project

npx create-next-app my-nextjs-app
Enter fullscreen mode Exit fullscreen mode

Replace my-nextjs-app with the name of your project.

Step 2: Install ESLint and Prettier

Navigate to your project directory and install ESLint, Prettier, and required plugins:

cd my-nextjs-app
npm install --save-dev eslint prettier eslint-plugin-react eslint-config-prettier eslint-plugin-prettier prettier-plugin-tailwindcss

Enter fullscreen mode Exit fullscreen mode

Step 3: Create ESLint Configuration

Create an ESLint configuration file named .eslintrc.js in your project root:

module.exports = {
  extends: ['next', 'next/core-web-vitals', 'eslint:recommended', 'plugin:react/recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
  plugins: ['react', '@typescript-eslint'],
  parserOptions: {
    ecmaVersion: 2021,
    sourceType: 'module',
  },
  rules: {
    // Add your custom ESLint rules here
  },
};
Enter fullscreen mode Exit fullscreen mode

Step 4: Create Prettier Configuration

Create a Prettier configuration file named .prettierrc.js in your project root:

module.exports = {
  semi: true,
  trailingComma: 'all',
  singleQuote: true,
  printWidth: 100,
  tabWidth: 2,
  plugins: ["prettier-plugin-tailwindcss"],
};
Enter fullscreen mode Exit fullscreen mode

Step 5: Configure VSCode (Optional)

If you're using Visual Studio Code, you can install the ESLint and Prettier extensions for automatic linting and formatting.

Step 6: Add Scripts to package.json

Add the following scripts to your package.json file:

"scripts": {
  "lint": "eslint .",
  "format": "prettier --write ."
}
Enter fullscreen mode Exit fullscreen mode

Step 7: Run ESLint and Prettier

npm run lint     # Run ESLint
npm run format   # Format code with Prettier
Enter fullscreen mode Exit fullscreen mode

Image of Stellar post

πŸš€ Stellar Dev Diaries Series: Episode 1 is LIVE!

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

Top comments (2)

Collapse
 
ilumin profile image
Lumin β€’

You have to use eslint@^8 since eslint@9 might have breaking changes.

Collapse
 
wldrocha profile image
Wladimir Rocha β€’

There is already a command inside that helps you with migration

Image of PulumiUP 2025

Let's talk about the current state of cloud and IaC, platform engineering, and security.

Dive into the stories and experiences of innovators and experts, from Startup Founders to Industry Leaders at PulumiUP 2025.

Register Now

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay