项目设置与 CLI
学习如何初始化新的 Next.js 15 项目,并使用命令行界面浏览基本项目结构
项目设置与 CLI 是 CoddyKit 上的免费 Next.js 15 Fullstack (App Router + Server Actions) 课时。 这是第 1 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Next.js 15 Fullstack (App Router + Server Actions) 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Next.js 15 Fullstack (App Router + Server Actions) 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Next.js 15: Your First Step
Welcome to Next.js 15 — the React framework for fast, scalable, production-ready apps. First up: spinning up a project and reading its structure from the CLI.
What You'll Need
Before you start, you need Node.js 18.17 or later — it provides the JavaScript runtime, and its package manager (npm, Yarn, or pnpm) installs your dependencies.
Initializing Your Project
Spin up a new project with create-next-app — it scaffolds everything for you. Just run this in your terminal.
npx create-next-app@latestSetup Prompts Explained
The CLI asks a few questions. The one that matters: say Yes to App Router — it's essential for Next.js 15. ESLint and Tailwind are nice; TypeScript is optional.
Navigating Your New Project
When it finishes you get a new project folder. Step into it with cd and you're ready to work.
cd my-next-appYour Project Structure
Know the key generated files: app/ holds your pages and layouts, public/ static assets, package.json your deps and scripts, next.config.js the config.
The Core `app` Directory
The app/ directory drives the App Router: layout.js for shared UI, page.js for a route's unique view, and globals.css for global styles.
Project Scripts & `npm run dev`
Your scripts live in package.json. The one you'll use constantly is npm run dev — it starts the development server.
npm run devHello Next.js!
With the dev server running, open localhost:3000 to see your app. That page is rendered by app/page.js — here's a stripped-down version.
export default function Home() {
return (
<main>
<h1>Hello CoddyKit!</h1>
</main>
);
}Quick Check: Setup Basics
You've learned how to kickstart a Next.js project. Let's test your knowledge!
Recap: Your First Next.js Steps
Recap: you set up Next.js 15 with create-next-app, explored the app/ directory, and launched the dev server. Next: file-system routing.
常见问题解答
「项目设置与 CLI」课时是免费的吗?
是的 — 「项目设置与 CLI」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Next.js 15 Fullstack (App Router + Server Actions) 课程的其余内容,请升级到 CoddyKit PRO。 Next.js 15 Fullstack (App Router + Server Actions) 课程共包含 4 节课。
「项目设置与 CLI」这节课中我会学到什么?
学习如何初始化新的 Next.js 15 项目,并使用命令行界面浏览基本项目结构 你通过在浏览器中直接运行的动手代码来练习 Next.js 15 Fullstack (App Router + Server Actions),全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Next.js 15 Fullstack (App Router + Server Actions) 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Next.js 15 Fullstack (App Router + Server Actions) 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 1 节课,共 4 节。
「项目设置与 CLI」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Next.js 15 Fullstack (App Router + Server Actions) 课中编写并运行代码吗?
能。每节 Next.js 15 Fullstack (App Router + Server Actions) 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- 项目设置与 CLI
- 文件系统路由基础
- 页面与布局概览
- 为您的 Next.js 应用添加样式