ssr-zero-layout-shift

Enforce SSR-first rendering with fixed-dimension server shells and client islands.

2|1|Updated Aug 24, 2024
One-click install
npx skills add https://github.com/armanisadeghi/ai-matrx --skill ssr-zero-layout-shift
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ssr-zero-layout-shift
Source: https://github.com/armanisadeghi/ai-matrx/tree/main/.cursor/skills/ssr-zero-layout-shift
Command: npx skills add https://github.com/armanisadeghi/ai-matrx --skill ssr-zero-layout-shift

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SSR-first rendering with zero layout shift eliminates CLS by ensuring server-rendered shells with client islands, and dynamic holes that fill without layout shifts; this approach improves perceived performance and stability of data-driven UIs.

Core Features & Use Cases

Seven composable patterns: server component shells with Client Component islands, Suspense boundaries as static-shell-with-dynamic-holes, selective hydration, lazy-loaded client components via next/dynamic, dimension-matched skeleton fallbacks, interaction-triggered data fetching, and one-shot Redux hydration. Use this strategy for pages, forms, dashboards, data tables, and any UI that fetches data, to prevent layout instability during loading.

Quick Start

Apply SSR-first patterns to your Next.js pages to eliminate CLS during data loading.

Frequently Asked Questions about ssr-zero-layout-shift

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent layout shift during data fetching in Next.js?

To prevent layout shift in Next.js, use SSR-first rendering with dimension-matched skeleton fallbacks and Suspense boundaries to ensure dynamic content loads without shifting the page layout.

What is the best way to structure React server components to avoid CLS?

The best way to avoid CLS is using server components as default fixed-dimension shells with minimal 'use client' directives, creating client islands that hydrate selectively without altering initial layout dimensions.

Does using Suspense boundaries help eliminate cumulative layout shift?

Yes, Suspense boundaries eliminate cumulative layout shift by acting as static shells with dynamic holes, maintaining visual stability while waiting for asynchronous data to load and hydrate.

How do I implement lazy-loaded client components without causing hydration mismatches?

Implement lazy-loaded client components via next/dynamic to enable selective hydration, ensuring components load only when needed without causing hydration mismatches or shifting existing layout elements.

Can I use this SSR-first approach for complex dashboards and data tables?

Yes, you can apply SSR-first patterns to complex dashboards and data tables by rendering fixed-dimension server shells and using interaction-triggered data fetching to guarantee zero CLS.