Next.jsReact启动器

fullstack-frontend-core — Next.js 启动器模板

作者 leonobitech

Leonobitech 全栈架构中的前端核心模板,基于 Next.js 15 与 TypeScript (ESM),通过 Docker 运行并接入 Traefik 反向代理,提供本地 HTTPS 访问的 Hello World 示例。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

3 个预览视图
桌面端首页1 / 3
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 3

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-14查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

基于 Next.js 15 与 TypeScript (ESM),使用 App Router 和 Turbopack

02

通过 Docker 容器化,提供与生产环境相似的本地运行方式

03

集成 Traefik 3.x 反向代理,支持 HTTPS 路由与域名访问

04

使用 mkcert 生成本地受信任的 TLS 证书

05

包含 shadcn/ui 组件初始化与基础组件添加步骤

06

提供健康检查端点 /healthz 及对应的 Docker 健康检查配置

模板详细介绍

该仓库是 Leonobitech 全栈架构的前端核心部分,使用 Next.js 15 + TypeScript (ESM) 构建,运行在 Docker 中,可被 Traefik 自动发现并路由 HTTPS 流量(app.localhost 指向前端,api.localhost 指向后端)。README 将其定位为最小化设计,仅用于验证基础设施端到端可用性。

模板包含从脚手架创建 Next.js 应用、初始化 shadcn/ui、编写 Hello World 页面、Docker 化、添加健康检查端点以及接入 Traefik 的完整步骤。它假定项目位于包含 infra 和 backend 的同一根目录下,并依赖外部网络(如 leonobitech-net)和 mkcert 生成的本地证书。

README 未提供关于生产环境部署、性能指标或扩展性的具体说明,也未列出依赖清单中的具体版本号(除 Next.js 15 外)。

Next.js启动器

适合你的项目吗?

适用场景

  • 在本地搭建包含 Traefik 和 mkcert 的全栈开发环境,验证前端与后端及反向代理的连通性
  • 作为新前端项目的起点,快速获得 Next.js + TypeScript + Tailwind + shadcn/ui 的基础配置
  • 学习如何将 Next.js 应用 Docker 化并接入 Traefik 进行 HTTPS 路由

适合人群

  • 熟悉 Docker 和 Traefik 的开发者
  • 需要本地模拟生产级 HTTPS 全栈环境的团队
  • 希望以最小化示例验证基础设施配置的用户

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    需在根目录下创建 repositories/frontend 并执行 create-next-app 脚手架命令

  2. 2

    需初始化 shadcn/ui 并添加 button、card 等基础组件

  3. 3

    需创建 Dockerfile 和 .dockerignore,并添加 /healthz 路由用于健康检查

  4. 4

    需在根 docker-compose.yml 中添加 frontend 服务,并配置 Traefik 标签和外部网络

  5. 5

    需确保 .env 中设置 FRONTEND_DOMAIN=app.localhost,并已安装 mkcert 证书

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
  • 该模板设计为放置在包含 infra 和 backend 的同一根目录下,需与 Leonobitech 全栈架构的其他仓库配合使用。
  • 需连接到与其余技术栈相同的 Traefik 外部网络(如 leonobitech-net),网络名称需根据实际环境替换。
  • 需确保根目录 .env 文件中包含 FRONTEND_DOMAIN=app.localhost 配置。
  • 若使用 infra 仓库中的 mkcert,证书才会被信任并显示锁图标,否则浏览器可能提示 TLS 警告。
  • 遇到 TLS 警告时需重新运行 mkcert 并重载 Traefik,具体参见 infra README。
  • 测试容器时需停止本地 npm run dev,以避免 3000 端口冲突。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

This project is designed to sit inside the same root alongside **infra** and **backend**:

README 原文

We’ll connect to the **same Traefik network** used by the rest of the stack (replace the network name if yours differs — e.g., `proxy` vs `leonobitech-net`). The example below assumes an external network named `leonobitech-net` and an `.env` with `FRONTEND_DOMAIN=app.localhost`.

README 原文

> Ensure your root .env contains:

README 原文

If you’re using **mkcert** from the infra repo, the cert will be trusted and the browser will show the lock icon.

README 原文

- **TLS warning** → Re-run mkcert and reload Traefik (see infra README).

README 原文

- **Port conflict 3000** → Stop local `npm run dev` when testing the container.

README 原文
https://github.com/leonobitech/fullstack-frontend-core/blob/main/LICENSEhttps://github.com/leonobitech/fullstack-frontend-core/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-14。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料一般 · 74 / 100
技术栈
Next.js · React
网站类型
启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2025-10-10
截图检查日期
2026-10-14

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: codex-user-requested-batch-review-20261015 · 2026-10-15

查看当时使用的来源资料

SHA-256: e7cd0d506d8edc51a80d345f69ec7db7974d63ab5ef8a70307cff5dc44588ffb

2026-10-14T14:43:02.237Z

来源文件 / 仓库
# fullstack-frontend-core

<p align="center"> <img src="./assets/banner-002.png" alt="Fullstack Frontend Core — Leonobitech" width="100%" /> </p>

Frontend foundation built with **Next.js 15 + TypeScript (ESM)** — containerized and ready to connect with the existing **Traefik infrastructure**.

A minimal “Hello World” app designed to run locally **as if it were in production**.

**FROM LOCALHOST TO PRODUCTION — BUILT LIKE A HACKER**

<p align="center"> <!-- Repo metrics --> <a href="https://github.com/leonobitech/fullstack-infrastructure-blueprint/stargazers"> <img src="https://img.shields.io/github/stars/leonobitech/fullstack-infrastructure-blueprint?style=flat-square" alt="GitHub stars" /> </a> <a href="https://github.com/leonobitech/fullstack-infrastructure-blueprint/network/members"> <img src="https://img.shields.io/github/forks/leonobitech/fullstack-infrastructure-blueprint?style=flat-square" alt="GitHub forks" /> </a> <a href="https://github.com/leonobitech/fullstack-infrastructure-blueprint/issues"> <img src="https://img.shields.io/github/issues/leonobitech/fullstack-infrastructure-blueprint?style=flat-square" alt="Open issues" /> </a> <a href="https://github.com/leonobitech/fullstack-infrastructure-blueprint/blob/main/LICENSE"> <img src="https://img.shields.io/github/license/leonobitech/fullstack-infrastructure-blueprint?style=flat-square" alt="License" /> </a> <img src="https://img.shields.io/github/last-commit/leonobitech/fullstack-infrastructure-blueprint?style=flat-square" alt="Last commit" /> <br/> <!-- Tech badges --> <a href="https://www.docker.com/"> <img src="https://img.shields.io/badge/Docker-ready-blue.svg?style=flat-square" alt="Docker" /> </a> <a href="https://traefik.io/"> <img src="https://img.shields.io/badge/Traefik-3.x-green.svg?style=flat-square" alt="Traefik 3.x" /> </a> <a href="https://github.com/FiloSottile/mkcert"> <img src="https://img.shields.io/badge/HTTPS-mkcert-orange.svg?style=flat-square" alt="HTTPS mkcert" /> </a> <img src="https://img.shields.io/badge/status-stable-success.svg?style=flat-square" alt="Status: stable" /> </p>

---

## 🧠 Overview

This repository represents the **frontend core** of the Leonobitech full-stack architecture.

It uses **Next.js 15 + TypeScript (ESM)**, runs in Docker, and is automatically discoverable by **Traefik** for HTTPS routing (`app.localhost` → frontend, `api.localhost` → backend).

It’s minimal by design — just enough to prove your infrastructure works **end-to-end**.

---

## 🧱 Stack

| Layer                   | Component               | Purpose                          |
| ----------------------- | ----------------------- | -------------------------------- |
| ⚛️ **Next.js 15**       | React framework         | SSR + static pages + API routes  |
| 🦾 **TypeScript (ESM)** | Modern language support | Type safety + cleaner DX         |
| 🐳 **Docker**           | Runtime isolation       | Production-like local execution  |
| ⚡ **Traefik 3.x**      | Reverse proxy           | HTTPS, domain routing            |
| 🔐 **mkcert**           | Local TLS               | Trusted local HTTPS certificates |

---

## 📦 Where this repo lives (root layout)

This project is designed to sit inside the same root alongside **infra** and **backend**:

```
root/
├─ assets/
├─ Docs/
│  ├─ README_BACKEND.md
│  └─ README_INFRA.md
├─ repositories/
│  ├─ core/          # backend (Node + TS + Hexagonal)
│  └─ frontend/      # <-- we will create this now
├─ traefik/
├─ .env
├─ .env.example
├─ docker-compose.yml
├─ docker-compose.local.yml
├─ docker-compose.prod.yml
├─ LICENSE
├─ Makefile
└─ README.md

```

---

## Create `repositories/frontend` and scaffold Next.js

From the **root** of your stack:

```bash
# 1) Ensure the parent folder exists
mkdir -p repositories
cd repositories

# 2) Create a Next.js app in "frontend"
#    (pick one: npm / pnpm / yarn)
npx create-next-app@latest frontend \
  --ts --eslint --app --src-dir false --tailwind \
  --use-npm --turbopack --import-alias "@/*"

# If you prefer pnpm:
pnpm dlx create-next-app@latest frontend \
  --ts --eslint --app --src-dir false --tailwind \
  --use-pnpm --turbopack --import-alias "@/*"

```

**Why this?**

- **App Router** and **ESM** by default.
- **Tailwind** ready out of the box.
- **Turbopack** for a faster dev server.
- Keeps the default alias **`@/*`** across the project.

---

### Initialize shadcn/ui

We prefer **CNA + shadcn init** (more control) over opinionated templates.

```bash
cd repositories/frontend

npx shadcn@latest init
```

- Select Base color: `zinc` or `slate` ( Optional )

### Add some base components:

```bash
npx shadcn@latest add button card input textarea select dialog sonner
```

## Replace the base page (Hello World)

**`app/layout.tsx`**

```tsx
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";

const geistSans = Geist({
  variable: "--font-geist-sans",
  subsets: ["latin"],
});

const geistMono = Geist_Mono({
  variable: "--font-geist-mono",
  subsets: ["latin"],
});

export const metadata: Metadata = {
  title: "Frontend Core — Leonobitech",
  description: "Next.js + TypeScript + Tailwind + shadcn/ui minimal core",
};

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en">
      <body
        className={`${geistSans.variable} ${geistMono.variable} min-h-dvh bg-background text-foreground antialiased p-6`}
      >
        {children}
      </body>
    </html>
  );
}
```

**`app/page.tsx`**

```tsx
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";

export default function HomePage() {
  return (
    <main className="max-w-xl mx-auto grid gap-4">
      <h1 className="text-2xl font-semibold">🚀 Frontend Core — Hello World</h1>
      <Card>
        <CardHeader>
          <CardTitle>Stack</CardTitle>
        </CardHeader>
        <CardContent className="space-y-2">
          <p>Next.js 15 + TypeScript + Tailwind + Turbopack + shadcn/ui</p>
          <Button>It works</Button>
        </CardContent>
      </Card>
    </main>
  );
}
```

---

## Internal directory tree (after scaffold + shadcn)

```
repositories/frontend/
├─ public/
├─ src/app/
│      ├─ page.tsx
│      └─ layout.tsx
├─ .gitignore
├─ components.json
├─ eslint.config.mjs
├─ next-env.d.ts
├─ next.config.ts
├─ package.json
├─ postcss.config.mjs
├─ README.md
└─ tsconfig.json

```

---

## Run locally (without Docker)

From `repositories/frontend/`:

```bash
npm run dev
# visit http://localhost:3000
```

Build & start (prod mode, still without Docker):

```bash
npm run build && npm start
```

---

## Dockerize the frontend

Create a **Dockerfile** inside `repositories/frontend/`:

```docker
# --- Builder ---
FROM node:22-alpine AS builder
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

# --- Runtime ---
FROM node:22-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

# curl para healthcheck
RUN apk add --no-cache curl

COPY --from=builder /app/package*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public

EXPOSE 3000
CMD ["npm", "run", "start"]
```

**`.dockerignore`**

```
node_modules
.next
.git
.gitignore
Dockerfile
README.md
.env
.env.*
*.log

```

---

## Recommended snippet (fast and no cache)

To make healthcheck faster and more stable, create a lightweight endpoint that always responds 200

```bash
// src/app/healthz/route.ts
export function GET() {
  return new Response("ok", {
    status: 200,
    headers: {
      "content-type": "text/plain; charset=utf-8",
      "cache-control": "no-store",
    },
  });
}
```

```bash
healthcheck:
  test: ["CMD-SHELL", "curl -fsS http://localhost:3000/healthz >/dev/null || exit 1"]
  interval: 15s
  timeout: 3s
  retries: 3
  start_period: 10s
```

## Add the service to your root `docker-compose.yml`

We’ll connect to the **same Traefik network** used by the rest of the stack (replace the network name if yours differs — e.g., `proxy` vs `leonobitech-net`). The example below assumes an external network named `leonobitech-net` and an `.env` with `FRONTEND_DOMAIN=app.localhost`.

```yaml
frontend:
  build:
    context: ./repositories/frontend
    dockerfile: Dockerfile
  image: frontend:v1.0.0
  container_name: frontend

  restart: unless-stopped

  environment:
    - NODE_ENV=production

  networks:
    - leonobitech-net

  depends_on:
    traefik:
      condition: service_started

  # 🔍 Healthcheck: using a lightweight endpoint
  healthcheck:
    test:
      [
        "CMD-SHELL",
        "curl -fsS http://localhost:3000/healthz >/dev/null || exit 1",
      ]
    interval: 15s
    timeout: 3s
    retries: 3
    start_period: 10s

  labels:
    - "traefik.enable=true"
    # HTTPS router: https://app.localhost
    - "traefik.http.routers.frontend.rule=Host(`${FRONTEND_DOMAIN}`)"
    - "traefik.http.routers.frontend.entrypoints=websecure"
    - "traefik.http.routers.frontend.tls=true"
    # Forward to container port 3000
    - "traefik.http.services.frontend.loadbalancer.server.port=3000"
    # Optionally attach middlewares defined under traefik/dynamic
    # - "traefik.http.routers.frontend.middlewares=secure-strict@file"
```

> Ensure your root .env contains:
>
> ```
> FRONTEND_DOMAIN=app.localhost
> ```

---

## Bring it up with Traefik

From the **root**:

```bash
docker compose up -d --build frontend
# or build the whole stack if Traefik is not up yet:
# docker compose up -d --build

# Options:
docker ps
docker logs -f frontend
```

Open:

- [**https://app.localhost**](https://app.localhost/) → Frontend Core
- [**https://traefik.localhost**](https://traefik.localhost/) → Dashboard (if enabled)

If you’re using **mkcert** from the infra repo, the cert will be trusted and the browser will show the lock icon.

---

## Troubleshooting

- **404 from Traefik** → Check labels and the **external network name**.
- **TLS warning** → Re-run mkcert and reload Traefik (see infra README).
- **Port conflict 3000** → Stop local `npm run dev` when testing the container.
- **Not using your host** → Confirm `.env FRONTEND_DOMAIN` and the router rule.

## 🧠 Philosophy

> “Production is not a deployment — it’s a mindset.”

This repository completes the local triad:

| Repo                                    | Role                                  |
| --------------------------------------- | ------------------------------------- |
| 🧱 `fullstack-infrastructure-blueprint` | Traefik + mkcert base                 |
| ⚙️ `fullstack-backend-core`             | API core (Node + Express + Hexagonal) |
| 🖥️ `fullstack-frontend-core`            | Frontend (Next.js + TypeScript)       |

Together, they simulate a **real production-grade full stack**, entirely on your laptop.

---

## 🔗 Verify Full Stack

```bash
docker compose up -d --build traefik core frontend
```

After all three repos are up:

- `https://traefik.localhost` → Traefik dashboard
- `https://api.localhost` → Backend core
- `https://app.localhost` → Frontend core

✅ Everything runs locally under HTTPS — just like in production.

---

## 🪐 Tags

`frontend`, `nextjs`, `typescript`, `esm`, `docker`, `traefik`, `mkcert`, `production-like`, `leonobitech`, `fullstack`, `infrastructure`

---

## 📜 License

MIT © 2025 — Felix Figueroa @ Leonobitech

---

<p align="center"> <strong>🥷 Leonobitech Dev Team</strong><br/> <a href="https://www.leonobitech.com" target="_blank">https://www.leonobitech.com</a><br/> Made with 🧠, 🥷, and Docker love 🐳 </p>

---

🔥 *This isn’t just a frontend. It’s your bridge between infrastructure and imagination.*
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。