frontend-api-client-with-jwt
A conceptual skill for building an API client in Next.js that handles JWT tokens
Best use case
frontend-api-client-with-jwt is best used when you need a repeatable AI agent workflow instead of a one-off prompt. It is especially useful for teams working in multi. A conceptual skill for building an API client in Next.js that handles JWT tokens
A conceptual skill for building an API client in Next.js that handles JWT tokens
Users should expect a more consistent workflow output, faster repeated execution, and less time spent rewriting prompts from scratch.
Practical example
Example input
Use the "frontend-api-client-with-jwt" skill to help with this workflow task. Context: A conceptual skill for building an API client in Next.js that handles JWT tokens
Example output
A structured workflow result with clearer steps, more consistent formatting, and an output that is easier to reuse in the next run.
When to use this skill
- Use this skill when you want a reusable workflow rather than writing the same prompt again and again.
When not to use this skill
- Do not use this when you only need a one-off answer and do not need a reusable workflow.
- Do not use it if you cannot install or maintain the related files, repository context, or supporting tools.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/frontend-api-client-with-jwt/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How frontend-api-client-with-jwt Compares
| Feature / Agent | frontend-api-client-with-jwt | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
A conceptual skill for building an API client in Next.js that handles JWT tokens
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Frontend API Client with JWT Skill
## When to Use This Skill
Use this conceptual skill when you need to implement a robust API client in Next.js that properly handles JWT tokens for authentication. This skill is appropriate for:
- Creating centralized API communication layer in Next.js applications
- Managing JWT-based authentication across multiple API endpoints
- Handling token expiration and refresh scenarios
- Standardizing error response parsing and handling
- Implementing secure API communication patterns
This skill should NOT be used for:
- Applications without JWT-based authentication
- Static sites without API communication needs
- Applications using alternative authentication methods (API keys, OAuth 2.0 client credentials, etc.)
- Simple applications with minimal API interaction
## Prerequisites
- Next.js application (either App Router or Pages Router)
- Understanding of JWT (JSON Web Token) concepts
- Knowledge of HTTP headers and authorization mechanisms
- Basic understanding of asynchronous JavaScript operations
- Awareness of client-side vs server-side execution contexts
## Conceptual Implementation Framework
### Authorization Header Attachment Capability
- Automatically attach JWT tokens to API requests as Authorization headers
- Determine when to include tokens based on request type and endpoint
- Handle token attachment for both client-side and server-side requests
- Manage token inclusion in cross-origin requests appropriately
- Ensure proper header formatting ("Bearer <token>")
### Token Expiry Handling Capability
- Detect JWT token expiration before making API requests
- Implement automatic token refresh mechanisms
- Handle token refresh failures gracefully
- Maintain session continuity during token refresh
- Coordinate token refresh across multiple concurrent requests
- Store updated tokens securely after refresh
### Error Response Parsing Capability
- Parse structured error responses from API endpoints
- Identify authentication-related errors (401, 403) for special handling
- Extract meaningful error messages for user feedback
- Handle different error response formats consistently
- Distinguish between client errors, server errors, and network issues
- Provide appropriate user feedback based on error types
### API Call Centralization Capability
- Create a unified interface for all API communications
- Standardize request and response handling across the application
- Implement consistent error handling and logging
- Manage request/response interceptors for cross-cutting concerns
- Provide type-safe API call patterns (when using TypeScript)
- Enable request caching and deduplication where appropriate
## Expected Input/Output
### Input Requirements:
1. **JWT Token Management**:
- Valid JWT token for authorization
- Token refresh endpoint configuration
- Token storage mechanism (localStorage, cookies, etc.)
- Token expiration time and refresh timing
2. **API Configuration**:
- Base API URL for requests
- Request timeout settings
- Custom headers and request options
- Endpoint-specific configurations
3. **Request Parameters**:
- HTTP method (GET, POST, PUT, DELETE, etc.)
- Request URL or endpoint identifier
- Request body for POST/PUT operations
- Query parameters and path variables
### Output Formats:
1. **Successful API Response**:
- HTTP 200-299 status codes
- Parsed response data matching expected format
- Updated token information when applicable
- Consistent response structure across all endpoints
2. **Authentication Error Response**:
- HTTP 401 Unauthorized for expired/invalid tokens
- Automatic token refresh attempt
- Redirect to login page after refresh failure
- Clear error messaging for authentication issues
3. **Authorization Error Response**:
- HTTP 403 Forbidden for insufficient permissions
- Appropriate error handling based on permission level
- User feedback for access restriction
4. **General Error Response**:
- Structured error object with message and code
- Appropriate HTTP status code
- Detailed error information for debugging
- User-friendly error messages for UI display
## Integration Patterns
### Client-Side Integration
- Handle API calls from client components and client-side rendering
- Manage token storage and retrieval in browser context
- Implement request interceptors for header attachment
- Coordinate with authentication state management
### Server-Side Integration (when applicable)
- Handle API calls from server components
- Manage token transmission securely between server and client
- Implement server-side token validation
- Handle server-side error responses appropriately
### React Component Integration
- Provide hooks for API communication in functional components
- Enable context-based API client access
- Support both functional and class component patterns
- Implement proper cleanup and cancellation mechanisms
## Security Considerations
1. **Token Storage**: Secure JWT token storage to prevent XSS attacks
2. **Header Transmission**: Use HTTPS for all API communications
3. **Token Refresh**: Implement secure token refresh mechanisms
4. **Error Information**: Avoid exposing sensitive information in error messages
5. **Request Validation**: Validate request parameters before sending
6. **Response Validation**: Verify response integrity and format
7. **Cross-Site Requests**: Implement proper CORS handling
## Performance Implications
- Optimize token retrieval and attachment for minimal overhead
- Implement efficient token refresh to avoid blocking requests
- Consider request caching strategies for improved performance
- Minimize redundant API calls through proper state management
- Implement request batching where appropriate
- Monitor and optimize network request timing
## Error Handling and Validation
- Validate JWT token format and expiration before requests
- Handle network connectivity issues gracefully
- Implement retry mechanisms for transient failures
- Provide fallback behaviors for critical API failures
- Log errors appropriately for debugging without exposing sensitive information
- Implement circuit breaker patterns for service resilience
## Testing Considerations
- Test token attachment functionality with valid/invalid tokens
- Verify token refresh mechanisms work correctly
- Validate error response parsing across different error types
- Test API client behavior in both client and server contexts
- Verify proper cleanup and cancellation of requests
- Test concurrent request handling and token refresh coordinationRelated Skills
frontend-ui-dark-ts
Build dark-themed React applications using Tailwind CSS with custom theming, glassmorphism effects, and Framer Motion animations. Use when creating dashboards, admin panels, or data-rich interfaces with a refined dark aesthetic.
frontend-slides
Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.
frontend-mobile-security-xss-scan
You are a frontend security specialist focusing on Cross-Site Scripting (XSS) vulnerability detection and prevention. Analyze React, Vue, Angular, and vanilla JavaScript code to identify injection poi
frontend-mobile-development-component-scaffold
You are a React component architecture expert specializing in scaffolding production-ready, accessible, and performant components. Generate complete component implementations with TypeScript, tests, s
frontend-developer
Build React components, implement responsive layouts, and handle client-side state management. Masters React 19, Next.js 15, and modern frontend architecture. Optimizes performance and ensures accessibility. Use PROACTIVELY when creating UI components or fixing frontend issues.
cc-skill-frontend-patterns
Frontend development patterns for React, Next.js, state management, performance optimization, and UI best practices.
frontend-dev
Full-stack frontend development combining premium UI design, cinematic animations, AI-generated media assets, persuasive copywriting, and visual art. Builds complete, visually striking web pages with real media, advanced motion, and compelling copy. Use when: building landing pages, marketing sites, product pages, dashboards, generating media assets (image/video/audio/music), writing conversion copy, creating generative art, or implementing cinematic scroll animations.
design-taste-frontend
Senior UI/UX Engineer. Architect digital interfaces overriding default LLM biases. Enforces metric-based rules, strict component architecture, CSS hardware acceleration, and balanced design engineering.
frontend-code-review
Trigger when the user requests a review of frontend files (e.g., `.tsx`, `.ts`, `.js`). Support both pending-change reviews and focused file reviews while applying the checklist rules.
expo-dev-client
Build and distribute Expo development clients locally or via TestFlight
frontend-responsive
Implement mobile-first responsive designs with fluid layouts, breakpoints, relative units, and touch-friendly interfaces that work across all device sizes. Use this skill when writing or modifying React components (.tsx, .jsx files), when implementing CSS or Tailwind responsive utilities (sm:, md:, lg:, xl: breakpoints), when working on layout components, navigation menus, grid systems, when optimizing for mobile devices, tablets, or desktop screens, when implementing media queries, when ensuring touch-friendly UI elements, or when testing cross-device compatibility.
frontend-css
Write consistent, maintainable CSS following the project's methodology (Tailwind utility classes) while minimizing custom CSS and adhering to design system tokens. Use this skill when writing or editing CSS files, Tailwind classes in React components (.tsx, .jsx files), when implementing design system colors/spacing/typography, when using Tailwind utility classes, when deciding between framework utilities vs. custom CSS, when optimizing CSS for production with tree-shaking, when configuring Tailwind theme extensions, or when maintaining design consistency across the application.