DEV Community

Cover image for Setup a latest Next.js project with Typescript, Tailwind CSS and Storybook 2023
Anik Routh
Anik Routh

Posted on • Updated on

Setup a latest Next.js project with Typescript, Tailwind CSS and Storybook 2023

Installation :

To create a new Next.js latest app run this command, it will install Typescript , ESLint automatically.

npx create-next-app@latest

After finish install / create Next.js app, we have to install Tailwind CSS! To install run this command

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

Now create tailwind.config.js file into Next.js app root folder and paste bellow code into the file.

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./app/**/*.{js,ts,jsx,tsx,mdx}",
    "./pages/**/*.{js,ts,jsx,tsx,mdx}",
    "./components/**/*.{js,ts,jsx,tsx,mdx}",

    // Or if using `src` directory:
    "./src/**/*.{js,ts,jsx,tsx,mdx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
Enter fullscreen mode Exit fullscreen mode

Now open the globals.css file and paste bellow code.

@tailwind base;
@tailwind components;
@tailwind utilities;
Enter fullscreen mode Exit fullscreen mode

We finished Tailwind CSS setup👏! Let’s setup Story Book! To install Story Book run this command

npx storybook@latest init

And to run it

npm run storybook
OR
npm run storybook
OR
pnpm run storybook
Enter fullscreen mode Exit fullscreen mode

It will run on 6006 port

http://localhost:6006

đź‘ŹHurrah! we finished the setup!

Check out my nextjs-tailwindcss-storybook-typescript quick start template on github.🤩 please start the repo to get new updates!

This is a Nextjs 13.3.4 | tailwindcss 3.3.2 | typescript 5.0.4 | storybook 7.0.8 | eslint 8.39.0 quick start template

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:3000 with your browser to see the result.

To, run the stroy book:

npm run storybook
Enter fullscreen mode Exit fullscreen mode

Open http://localhost:6006 stroy book live link with your browser to see the result.

You can start editing the page by modifying pages/index.tsx. The page auto-updates as you edit the file.

API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts.

The pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Learn More

To learn more about Next.js, take a look at the following…




Thank you for reading my post! Here is my website check it out.

Top comments (0)