borghei/Claude-Skills / engineering/senior-frontend
senior-frontend
VerifiedScaffold Next.js 16 or React + Vite 8 apps, generate components with tests and stories, and flag heavy bundle dependencies. Use when starting a React project, adding components or hooks, or reviewing frontend code or performance.
assets/templates/scaffold/files/auth_client.ts
View on GitHubimport { useSyncExternalStore } from 'react';
// Client-side session state for a single-page app. It only remembers the token
// your server issued; it proves nothing on its own. Real authentication needs a
// server that checks credentials, issues the token and verifies it on every API call.
const STORAGE_KEY = 'auth-token';
const listeners = new Set<() => void>();
function readToken(): string | null {
try {
return window.sessionStorage.getItem(STORAGE_KEY);
} catch {
return null;
}
}
function notify(): void {
listeners.forEach((listener) => listener());
}
function subscribe(listener: () => void): () => void {
listeners.add(listener);
return () => {
listeners.delete(listener);
};
}
export function getToken(): string | null {
return readToken();
}
export function setToken(token: string): void {
try {
window.sessionStorage.setItem(STORAGE_KEY, token);
} catch {
// Storage blocked (private mode, quota); the session lasts until reload.
}
notify();
}
export function clearToken(): void {
try {
window.sessionStorage.removeItem(STORAGE_KEY);
} catch {
// Nothing stored.
}
notify();
}
export function useAuth() {
const token = useSyncExternalStore(subscribe, readToken, () => null);
return { token, isAuthenticated: token !== null, signIn: setToken, signOut: clearToken };
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |