Fetch API, Caching, and Revalidation strategies.
Fetch data directly in Server Components using async/await.
Next.js extends the native fetch API for granular caching control.
fetch('https://api.com') -> cache: 'force-cache'. Built at build time.fetch('...', { cache: 'no-store' }). Fetched on every request.fetch('...', { next: { revalidate: 60 } }). Cached for 60s.Colocation: Fetch data where it's used. Next.js automatically deduplicates requests for the same URL in the same render pass.
Parallel: Use Promise.all() to prevent waterfalls.
const [user, posts] = await Promise.all([getUser(), getPosts()]);
Blocking: To prevent UI blocking, wrap the component in <Suspense> and stream the result.
revalidatePath('/blog/[slug]') - Purges cache for specific route.revalidateTag('collection') - Purges all fetches tagged with next: { tags: ['collection'] }.Server Components are the default, but for live/user-specific data that doesn't need SEO:
SWR / TanStack Query: PREFERRED over useEffect. Handles caching, polling, and deduplication automatically.
'use client';
import useSWR from 'swr';
// Good: "Stale-While-Revalidate" - Fast UI, then updates
const { data } = useSWR('/api/user', fetcher);
Anti-Pattern: Do not use useEffect to fetch data if you can avoid it. It causes "Flash of Loading Content" and waterfalls.
/api/...) from Server Components. Call the DB/Service function directly.Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer