Skip to content

rgxdev/nextjs-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Next.js Template mit TanStack

Ein modernes, sicheres Next.js Template mit TanStack-Bibliotheken, TypeScript und sicheren Coding-Praktiken.

πŸš€ Features

TanStack Integration

  • TanStack Query: Datenabfrage, Caching und Synchronisation
  • TanStack Form: Typsichere Formular-Validierung mit Zod
  • TanStack Table: Leistungsstarke Datentabellen mit Sortierung und Paginierung

Sicherheit & Best Practices

  • 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

Development Experience

  • Prettier: Automatische Code-Formatierung
  • ESLint: Strenge Linting-Regeln
  • TypeScript: Modernste TypeScript-Konfiguration
  • Tailwind CSS: Utility-first CSS Framework
  • shadcn/ui: Hochwertige UI-Komponenten

πŸ“¦ Installation

# Repository klonen
git clone <repository-url>
cd nextjs-template

# AbhΓ€ngigkeiten installieren
npm install

# Development Server starten
npm run dev

πŸ› οΈ Scripts

npm 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 formatieren

πŸ—οΈ Projektstruktur

src/
β”œβ”€β”€ 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

πŸ”’ Sicherheits-Features

TypeScript Konfiguration

  • strict: true
  • noImplicitAny: true
  • noUncheckedIndexedAccess: true
  • exactOptionalPropertyTypes: true

Content Security Policy

  • Strict CSP mit Nonce-based Script Loading
  • Blockierung von unsafe-inline und unsafe-eval
  • Schutz vor XSS-Angriffen

Security Headers

  • X-Frame-Options: DENY
  • X-Content-Type-Options: nosniff
  • Referrer-Policy: strict-origin-when-cross-origin
  • Strict-Transport-Security

Zod Schema Validation

// Beispiel Schema
const userSchema = z.object({
  id: z.string().min(1),
  name: z.string().min(2).max(50),
  email: z.string().email(),
});

πŸ“š TanStack Beispiele

TanStack Query

// Custom Hook fΓΌr Benutzer
export function useUsers() {
  return useQuery({
    queryKey: ["users"],
    queryFn: fetchUsers,
    staleTime: 5 * 60 * 1000,
  });
}

TanStack Form

// Formular mit Zod Validation
const form = useForm({
  defaultValues: { name: "", email: "" },
  validatorAdapter: zodValidator,
  onSubmit: async ({ value }) => {
    // Submit Logic
  },
});

TanStack Table

// Sortierbare Tabelle
const table = useReactTable({
  data,
  columns,
  getCoreRowModel: getCoreRowModel(),
  getSortedRowModel: getSortedRowModel(),
});

🎨 Styling

Das Template verwendet Tailwind CSS mit einem angepassten Design-System:

Theme-Konfiguration

  • Dark/Light Mode Support
  • Responsive Design
  • Accessibility-optimierte Farben
  • Custom CSS Variables

shadcn/ui Komponenten

  • Button, Card, Input, Textarea
  • Form-Komponenten
  • Layout-Komponenten

πŸ§ͺ API-Beispiele

Sichere API Routes

// /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 }
    );
  }
}

πŸ”§ Konfiguration

Environment Variables

NODE_ENV=development
NEXT_PUBLIC_APP_URL=http://localhost:3000

VS Code Extensions (Empfohlen)

  • TypeScript Importer
  • ESLint
  • Prettier
  • Tailwind CSS IntelliSense
  • Error Lens

πŸš€ Deployment

Vercel (Empfohlen)

npm run build
vercel --prod

Docker

FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]

πŸ“ Lizenz

MIT License - siehe LICENSE fΓΌr Details.

🀝 Beitragen

  1. Fork das Repository
  2. Erstelle einen Feature Branch (git checkout -b feature/amazing-feature)
  3. Committe deine Γ„nderungen (git commit -m 'Add amazing feature')
  4. Push zum Branch (git push origin feature/amazing-feature)
  5. Γ–ffne eine Pull Request

πŸ“ž Support

Bei Fragen oder Problemen ΓΆffne bitte ein Issue im Repository.


Gebaut mit ❀️ und modernsten Web-Technologien

About

NextJS Template with Light/dark Mode and SEO optimization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages