Next.js is awesome React framework.
This article describes how to set up TypeScript + Next.js.
nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
refs:
https://github.com/nvm-sh/nvm
Node
nvm install stable --latest-npm
nvm use stable
Instal
npx create-next-app@latest --typescript
refs:
https://nextjs.org/docs/getting-started
Run
npm run dev
Check
http://localhost:3000/
Setting absolute path
Move source code files to src
dir.
mkdir src
mv pages src/
mv styles src/
# tsconfig.json
{
"compilerOptions": {
# ...
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
},
# ...
}
// src/pages/_app.tsx
import '@/styles/globals.css'
// ...
Check
http://localhost:3000/
Remove example files
rm src/pages/index.tsx
rm src/styles/Home.module.css
rm src/pages/api/hello.ts
rm public/vercel.svg
Top comments (0)