Skip to content
Back to skills

Frontend Api

ASecurity

Connects a React + TypeScript frontend to a backend with finished code - API client, errors, login, token refresh, guarded routes, permissions, TanStack Query, upload. Use for API calls, services, auth, 401/403, query or mutation hooks, server validation errors. Not for building the backend.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
developmenttypescriptgoreactnodeapifrontendbackendsecurity

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Pandi2352/frontend-skills --skill frontend-api --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Frontend Api?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Frontend Api
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/pandi2352-frontend-api/badge)](https://www.skillsdirectory.com/skills/pandi2352-frontend-api)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: frontend-api
description: Connects a React + TypeScript frontend to a backend with finished code - API client, errors, login, token refresh, guarded routes, permissions, TanStack Query, upload. Use for API calls, services, auth, 401/403, query or mutation hooks, server validation errors. Not for building the backend.
---

# Frontend API and auth

Finished code; do not open or retype `assets/`. Projects made with `create.mjs` already
have it. Otherwise: `node <skill>/scripts/add-to-project.mjs <project>` (after
frontend-core), then `@tanstack/react-query` with `resolve-versions.mjs`.

```text
page → feature hook → feature service → services/api.ts
```

Only `services/api-client.ts` calls `fetch`. Write features with
`node scripts/generate.mjs feature …`; it makes service, hooks, pages and tests.

## Connect

1. OpenAPI file or backend code in reach: read that. Otherwise ask for base URL,
   login/refresh/logout/me endpoints, session type, roles. Do not invent them.
   No backend yet: build sample data for this project as `references/mock-data.md` says.
   No backend yet: build sample data for this project as  says.
2. Set `VITE_API_URL`. Adapt `features/auth/services/auth.service.ts` and each
   `*.service.ts`; different names are translated there and nowhere else.
3. Real roles in `config/permissions.ts`.
4. Providers: `QueryClientProvider` > `AuthProvider` > router.

## Session

Access token in memory, refresh token in an httpOnly, Secure, SameSite cookie.
Cookie-only: `refresh` returns null, and the server protects against CSRF. Tokens only
in JSON: say that local storage lets any XSS steal them, and ask first.

Built in: one refresh for many 401s, network failure does not sign out, sign out clears
the cache and reaches other tabs, token never goes to another host.

## Rules

- `signal` in every query. No automatic retry of mutations.
- Server data stays in the query cache. Filters, sort and page in URL and key.
- `getErrorMessage(error)`, never raw bodies. `ApiError.fieldErrors` reach the fields
  through `Form`.
- Optimistic changes undo on failure.
- Hiding a button is not security. No secrets in `VITE_`, no tokens in logs or URLs.

| Status | Behaviour |
| --- | --- |
| 400, 422 | below fields, rest on top of the form |
| 401 | refresh once, then sign out |
| 403, 404 | own state, no retry |
| 409 | explain, offer reload |
| 429 | wait, Retry-After |
| 5xx, network | message, retry, request id |

Login page, guards, permissions, upload by hand: `references/auth.md`.

Files in this skill

  • SKILL.md2.5 KB
  • assets/template/.env.example107 B
  • assets/template/src/config/env.ts367 B
  • assets/template/src/config/permissions.ts371 B
  • assets/template/src/features/auth/auth.test.tsx3.8 KB
  • assets/template/src/features/auth/components/AuthProvider.tsx1.9 KB
  • assets/template/src/features/auth/components/CanAccess.tsx408 B
  • assets/template/src/features/auth/components/route-guards.tsx1.9 KB
  • assets/template/src/features/auth/hooks/auth-context.ts1.1 KB
  • assets/template/src/features/auth/index.ts225 B
  • assets/template/src/features/auth/services/auth.service.ts843 B
  • assets/template/src/features/auth/types/auth.types.ts337 B
  • assets/template/src/features/auth/utils/safe-path.ts495 B
  • assets/template/src/lib/query-client.ts570 B
  • assets/template/src/services/api-client.test.ts4.8 KB
  • assets/template/src/services/api-client.ts4.6 KB
  • assets/template/src/services/api-error.ts3.6 KB
  • assets/template/src/services/api.ts812 B
  • assets/template/src/services/session.ts872 B
  • assets/template/src/services/upload.ts2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.