How to Set Up a NextJS Project with TypeScript
Begin
I want to record how to setting up a NextJS project with TypeScript.
Let’s go
Create a NextJS Project
1 | yarn create next-app --typescript [your project path] |
Yes, I used yarn. I prefer yarn to npm.
This article is very subjective. If you do not feel comfortable reading it. Please close it as soon as possible.
If you think my article can help you, you can subscribe to this site by using RSS.
Add an EditorConfig File
Add .editorconfig
file to root directory.
1 | # EditorConfig is awesome: https://EditorConfig.org |
Install Google TypeScript code style tools
1 | npx install gst |
and need add a line code to tsconfig.json
1 | { |
and remove src/index.ts
1 | rm src/index.ts |
Add VSCode setting.json
I used VSCode
Create new file .vscode/settings.json
1 | { |
Add TailWindCSS
I love tailwindcss. It is very useful. So I will add it on project.
Install Tailwind via
1 | yarn add -D tailwindcss@latest postcss@latest autoprefixer@latest |
Create your configuration files
1 | npx tailwindcss init -p |
Configure Tailwind to remove unused styles in production
1 | // tailwind.config.js |
Include Tailwind in your CSS
1 | /* ./styles/globals.css */ |
Now you can begin your work!
1 | yarn dev |
Reference
NextJS Document
What is EditorConfig?
Google TypeScript Style
Getting started with Tailwind CSS
Photo by Ferenc Almasi on Unsplash
How to Set Up a NextJS Project with TypeScript
https://iiiyu.com/2021/06/08/How-to-Set-Up-a-NextJS-Project-with-TypeScript/