loading
Guide to building Next.js loading.tsx skeleton pages that mirror page content structure. Use this skill whenever creating loading states, skeleton pages, or loading.tsx files for any page type — list pages, form sub-pages, detail overviews, cards grids, description lists, or custom content pages. Must be triggered when the user mentions loading page, skeleton, loading state, or loading.tsx.
What this skill does
# Loading Page Guide
Loading pages are Next.js files (`loading.tsx`) that show skeleton placeholders while the real page loads. They mirror the structure of their corresponding page — same layout components, same spacing, same hierarchy — but replace dynamic content with skeleton components.
## Workflow
1. Read the corresponding `page.tsx` to understand its structure
2. Identify the page type using the decision tree
3. Generate the loading file(s) using the matching pattern from [loading-patterns.md](./references/loading-patterns.md)
## Decision Tree
Analyze what the page imports and renders:
1. **List page?** (imports a list component, uses `Suspense`, has `force-dynamic`) → **List Loading**
2. **Form sub-page?** (imports a Form component or uses `FormLayout`) → **Form Sub-Page Loading**
3. **Detail overview?** (imports `TaskGroup` / `TaskPanel`, shows grouped tasks) → **Detail Overview Loading**
4. **Description list page?** (imports `DescriptionsList`) → **Description List Loading**
5. **Cards grid page?** (imports `CardsGridLayout` or renders card panels) → **Cards Grid Loading**
6. **Custom content page?** (documents, contracts, timeline, etc.) → **Custom Content Loading**
## File Structure
Loading pages follow a **two-file pattern**:
### 1. Page-level `loading.tsx` (in `src/app/...`)
Thin wrapper that imports and renders the feature-level loading component.
```tsx
import { FeatureLoading } from "@/features/{feature}/components/FeatureLoading";
export default function PageNameLoading() {
return <FeatureLoading />;
}
```
### 2. Feature-level loading component (in `src/features/...`)
Contains the actual skeleton layout. Lives alongside the feature's other components.
**Exception — List pages**: Only need the page-level `loading.tsx` since they delegate directly to the shared `ListLoading` component. No feature-level component needed.
## Available Skeleton Components
| Component | Import | Purpose |
|-----------|--------|---------|
| `BoxSkeleton` | `@finstreet/ui/components/base/Skeletons/BoxSkeleton` | Rectangular placeholder for content blocks |
| `TextSkeleton` | `@finstreet/ui/components/base/Skeletons/TextSkeleton` | Animated text lines (`lines`, `fontSize` props) |
| `AvatarSkeleton` | `@finstreet/ui/components/base/Skeletons/AvatarSkeleton` | Circular placeholder (`size` prop) |
## Shared Loading Components
| Component | Import | Use for |
|-----------|--------|---------|
| `ListLoading` | `@/shared/components/ListLoading` | List pages — accepts `title` prop |
| `FormSkeleton` | `@/shared/components/FormSkeleton` | Form pages — renders form field placeholders, no props |
| `SubPageHeaderSkeleton` | `@/shared/components/SubPageHeaderSkeleton` | Sub-pages — accepts `title` prop, renders back button + title + text skeleton |
## Server vs Client Components
- **Server (async)**: Use `getTranslations()` from `next-intl/server`. Export as `async function`.
- **Client**: Add `"use client"` directive. Use `useTranslations()` from `next-intl`.
Choose based on what the component needs:
- Only needs translations → prefer async server component with `getTranslations()`
- Needs hooks (`useParams`, etc.) → client component with `useTranslations()`
## Patterns
See [loading-patterns.md](./references/loading-patterns.md) for detailed code templates and examples of each loading type.
## Rules
1. The loading page must mirror the structure of its corresponding page — same layout hierarchy, same spacing
2. Use shared components (`ListLoading`, `FormSkeleton`, `SubPageHeaderSkeleton`) whenever the pattern matches — do not reinvent them
3. Translation namespaces must match the actual page's translation namespace
4. Page-level `loading.tsx` function name: `{RouteSegments}Loading` (PascalCase from route path)
5. Feature-level component name: `{FeatureName}Loading`
6. Do NOT import or call data-fetching functions — loading pages have no data
7. Do NOT search the project for existing loading pages or dependencies
8. Match gap sizes, grid column counts, and layout areas from the actual page
9. Skeleton dimensions should approximate the content they replace (e.g., a card that's ~200px tall → `BoxSkeleton height="200"`)
10. When the page has a description `Typography` with a translation key, the loading page should render that same translated text — descriptions are static and known at load time
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.