TypeScript Next.js Starter 项目教程

TypeScript Next.js Starter 项目教程

typescript-nextjs-starterNon-opinionated TypeScript starter for Next.js. All the tools you need to build your next project ⚡️项目地址:https://gitcode.com/gh_mirrors/ty/typescript-nextjs-starter

1. 项目的目录结构及介绍

typescript-nextjs-starter/
├── .github/
│   └── workflows/
├── .husky/
├── .vscode/
├── public/
│   ├── favicon.ico
│   └── vercel.svg
├── src/
│   ├── app/
│   │   ├── layout.tsx
│   │   └── page.tsx
│   ├── components/
│   │   ├── Button.tsx
│   │   └── Header.tsx
│   ├── styles/
│   │   └── globals.css
│   └── utils/
│       └── api.ts
├── .editorconfig
├── .eslintrc.json
├── .gitignore
├── .prettierrc
├── commitlint.config.js
├── next.config.js
├── package.json
├── README.md
├── tsconfig.json
└── yarn.lock

目录结构介绍

  • .github/workflows: 包含GitHub Actions的工作流配置文件。
  • .husky: 包含Husky的配置文件,用于在提交前运行脚本。
  • .vscode: 包含VSCode的配置文件,用于统一开发环境。
  • public: 包含公共静态资源,如favicon和Vercel的SVG图标。
  • src: 源代码目录。
    • app: Next.js 13的新特性,用于定义应用的路由和布局。
    • components: 包含React组件。
    • styles: 包含全局样式文件。
    • utils: 包含工具函数。
  • .editorconfig: 用于统一编辑器的配置。
  • .eslintrc.json: ESLint配置文件,用于代码检查。
  • .gitignore: Git忽略文件配置。
  • .prettierrc: Prettier配置文件,用于代码格式化。
  • commitlint.config.js: Commitlint配置文件,用于规范提交信息。
  • next.config.js: Next.js配置文件。
  • package.json: 项目依赖和脚本配置。
  • README.md: 项目说明文档。
  • tsconfig.json: TypeScript配置文件。
  • yarn.lock: Yarn锁定文件,用于确保依赖版本一致。

2. 项目的启动文件介绍

src/app/layout.tsx

这是Next.js 13的新特性,用于定义应用的全局布局。

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}

src/app/page.tsx

这是Next.js 13的新特性,用于定义应用的首页。

export default function Home() {
  return (
    <div>
      <h1>Welcome to Next.js!</h1>
    </div>
  )
}

3. 项目的配置文件介绍

next.config.js

Next.js的配置文件,可以自定义各种配置,如路由、构建选项等。

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
}

module.exports = nextConfig

tsconfig.json

TypeScript的配置文件,定义了TypeScript编译器的选项。

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "baseUrl": "./",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "include": ["next

typescript-nextjs-starterNon-opinionated TypeScript starter for Next.js. All the tools you need to build your next project ⚡️项目地址:https://gitcode.com/gh_mirrors/ty/typescript-nextjs-starter

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林广红Winthrop

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值