Ein modernes, sicheres Next.js Template mit TanStack-Bibliotheken, TypeScript und sicheren Coding-Praktiken.
- TanStack Query: Datenabfrage, Caching und Synchronisation
- TanStack Form: Typsichere Formular-Validierung mit Zod
- TanStack Table: Leistungsstarke Datentabellen mit Sortierung und Paginierung
- TypeScript Strict Mode: VollstΓ€ndige Typisierung mit strengen Konfigurationen
- Zod Schema Validation: Runtime-Validierung aller Eingaben
- Content Security Policy: Schutz vor XSS und Code-Injection
- Security Headers: Umfassende Sicherheitsheader
- ESLint Security Plugin: Automatische Erkennung von SicherheitslΓΌcken
- Prettier: Automatische Code-Formatierung
- ESLint: Strenge Linting-Regeln
- TypeScript: Modernste TypeScript-Konfiguration
- Tailwind CSS: Utility-first CSS Framework
- shadcn/ui: Hochwertige UI-Komponenten
# Repository klonen
git clone <repository-url>
cd nextjs-template
# AbhΓ€ngigkeiten installieren
npm install
# Development Server starten
npm run devnpm run dev # Development Server mit Turbopack
npm run build # Production Build
npm run start # Production Server
npm run lint # ESLint ausfΓΌhren
npm run typecheck # TypeScript Check
npm run format # Code formatierensrc/
βββ app/ # Next.js App Router
β βββ api/ # API Routes
β βββ globals.css # Globale Styles
β βββ layout.tsx # Root Layout
β βββ page.tsx # Homepage
β βββ providers.tsx # React Context Providers
βββ components/
β βββ examples/ # Beispiel-Komponenten
β βββ providers/ # Provider-Komponenten
β βββ ui/ # shadcn/ui Komponenten
β βββ core/ # Core-Komponenten
βββ hooks/ # Custom React Hooks
βββ lib/ # Utilities und Konfiguration
β βββ constants.ts # App-Konstanten
β βββ schemas.ts # Zod Schemas
β βββ utils.ts # Utility Functions
strict: truenoImplicitAny: truenoUncheckedIndexedAccess: trueexactOptionalPropertyTypes: true
- Strict CSP mit Nonce-based Script Loading
- Blockierung von unsafe-inline und unsafe-eval
- Schutz vor XSS-Angriffen
X-Frame-Options: DENYX-Content-Type-Options: nosniffReferrer-Policy: strict-origin-when-cross-originStrict-Transport-Security
// Beispiel Schema
const userSchema = z.object({
id: z.string().min(1),
name: z.string().min(2).max(50),
email: z.string().email(),
});// Custom Hook fΓΌr Benutzer
export function useUsers() {
return useQuery({
queryKey: ["users"],
queryFn: fetchUsers,
staleTime: 5 * 60 * 1000,
});
}// Formular mit Zod Validation
const form = useForm({
defaultValues: { name: "", email: "" },
validatorAdapter: zodValidator,
onSubmit: async ({ value }) => {
// Submit Logic
},
});// Sortierbare Tabelle
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
});Das Template verwendet Tailwind CSS mit einem angepassten Design-System:
- Dark/Light Mode Support
- Responsive Design
- Accessibility-optimierte Farben
- Custom CSS Variables
- Button, Card, Input, Textarea
- Form-Komponenten
- Layout-Komponenten
// /api/users/route.ts
export async function GET(request: NextRequest) {
try {
const validatedData = userSchema.array().parse(data);
return NextResponse.json(validatedData);
} catch (error) {
return NextResponse.json(
{ error: "Validation Error" },
{ status: 400 }
);
}
}NODE_ENV=development
NEXT_PUBLIC_APP_URL=http://localhost:3000- TypeScript Importer
- ESLint
- Prettier
- Tailwind CSS IntelliSense
- Error Lens
npm run build
vercel --prodFROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]MIT License - siehe LICENSE fΓΌr Details.
- Fork das Repository
- Erstelle einen Feature Branch (
git checkout -b feature/amazing-feature) - Committe deine Γnderungen (
git commit -m 'Add amazing feature') - Push zum Branch (
git push origin feature/amazing-feature) - Γffne eine Pull Request
Bei Fragen oder Problemen ΓΆffne bitte ein Issue im Repository.
Gebaut mit β€οΈ und modernsten Web-Technologien