> nextjs-data-access-layer
Secure, reusable data access patterns with DTOs and Taint checks. Use when building a data access layer with DTOs and server-side taint checking in Next.js. (triggers: **/lib/data.ts, **/services/*.ts, **/dal/**, DAL, Data Access Layer, server-only, DTO)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/nextjs-data-access-layer?format=md"Data Access Layer (DAL)
Priority: P1 (HIGH)
Centralize all data access (Database & External APIs) to ensure consistent security, authorization, and caching.
Principles
- Server-Only: Must include
import 'server-only'to prevent Client bundling. - Auth Co-location: Auth checks (
session.role) must be inside the DAL function. - DTO Transformation: Return plain objects (DTOs), never raw ORM instances.
- No Internal Fetch: Call DAL functions directly. Do not
fetch('localhost/api').
Implementation
| Approach | When to use | Reference |
|---|---|---|
| API Gateway (BFF) | Enterprise apps with separated Backend (NestJS). | Pattern A |
| Direct DB | Fullstack apps or Admin Panels. | Pattern B |
Limitations
- Client Components: Cannot import DAL files. Must use Server Actions or Route Handlers as bridges.
🚫 Anti-Patterns
- Do NOT use standard patterns if specific project rules exist.
- Do NOT ignore error handling or edge cases.
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)