static-rendering — Claude Code skill: SSG and build-time HTML
A skill that walks your agent through static generation: which pages can be pre-rendered to HTML at build time and how to do it in Next.js. Useful when content stays the same across requests.
npx skills add PatternsDev/skills --skill static-rendering -a claude-codeWhat static-rendering does
The skill covers SSG, where HTML for each route is produced during the build instead of on every request. It lists the pages that fit: About, blog posts, product listings. And the ones that don't: user dashboards, real-time feeds, anything behind authentication.
The hands-on part is Next.js. For listings and data-backed pages it points to getStaticProps in the Pages Router or async components in the App Router; for dynamic routes, getStaticPaths and generateStaticParams. ISR gets a mention for pages that need periodic updates, along with deploying to a CDN.
Build time is the real constraint. A large dataset makes the build impractical without ISR. Content changes also force a rebuild and redeploy, otherwise the page goes stale. One detail worth checking: the fallback: false example means a route with a missing id returns 404, so every path has to show up in getStaticPaths.
The skill links to the patterns.dev React write-up and sits alongside hooks-pattern and hoc-pattern.
What it helps with
- decide which pages can be pre-rendered at build time
- cut server request processing to improve TTFB
- generate HTML for dynamic routes with
getStaticPaths - fetch data from a database at build time without shipping it to the client bundle
- tell when SSG stops working and ISR is the better fit
Example prompts for the agent
- Set up static rendering for our product pages in Next.js
- Our TTFB is slow — should we move to SSG?
- Go through our routes and tell me which ones can't be statically generated
How to install static-rendering
1Skills CLI (Vercel)
npx skills add PatternsDev/skills --skill static-rendering -a claude-code2Manually: put the files in place
~/.claude/skills/static-rendering/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/static-rendering/
1Skills CLI (Vercel)
npx skills add PatternsDev/skills --skill static-rendering -a codex2Manually: put the files in place
.agents/skills/static-rendering/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add PatternsDev/skills --skill static-rendering -a cursor2Manually: put the files in place
.cursor/skills/static-rendering/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install PatternsDev/skills static-rendering2Manually: put the files in place
.github/skills/static-rendering/SKILL.md1Skills CLI (Vercel)
npx skills add PatternsDev/skills --skill static-rendering -a gemini-cli2Platform CLI
gemini skills install https://github.com/PatternsDev/skills --path react/static-renderingManually: put the files in place
.devin/skills/static-rendering/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add PatternsDev/skills --skill static-rendering -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about static-rendering
How do I install static-rendering in Claude?
Run npx skills add PatternsDev/skills --skill static-rendering -a claude-code. The skill lands in ~/.claude/skills/static-rendering/SKILL.md.
What does static-rendering do?
It teaches the agent static generation: pre-rendering pages to HTML at build time, fetching data with getStaticProps, and handling dynamic routes with getStaticPaths.
Which pages should not use SSG?
Anything that changes per request: dashboards, real-time feeds, auth-gated pages. Also watch out when the dataset is big enough to make builds impractical — the skill points to ISR there.
Source text
SKILL.md · MIT
---
name: static-rendering
description: Teaches static rendering (SSG) for build-time HTML generation. Use when your pages don't change per request and can be pre-rendered at build time for maximum cacheability and performance.
paths:
- "**/*.tsx"
- "**/*.jsx"
license: MIT
metadata:
author: patterns.dev
version: "1.1"
related_skills:
- "hooks-pattern"
- "hoc-pattern"
---
# Static Rendering
Based on our discussion on SSR, we know that a high request processing time on the server negatively affects the TTFB. Similarly, with CSR, a large JavaScript bundle can be detrimental to the FCP, LCP and TTI of the application due to the time taken to download and process the script.
Static rendering or static generation (SSG) attempts to resolve these issues by delivering pre-rendered HTML content to the client that was generated when the site was built.
## When to Use
- Use this for static content like About pages, blog posts, and product listings that don't change per-request
- This is helpful when you want the fastest possible TTFB via CDN-served static HTML
## When NOT to Use
- For highly dynamic, personalized content that changes per request (e.g., user dashboards, real-time feeds)
- When the dataset is so large that build times become impractical without ISR
- For pages requiring authentication-gated content that can't be pre-rendered at build time
## Instructions
- Use `getStaticProps` (Pages Router) or async components (App Router) to fetch data at build time
- Use `getStaticPaths` / `generateStaticParams` to pre-render dynamic routes
- Consider Incremental Static Regeneration (ISR) for pages that need periodic updates
- Deploy to a CDN for edge-cached performance
## Details
A static HTML file is generated ahead of time corresponding to each route that the user can access. These static HTML files may be available on a server or a CDN and fetched as and when requested by the client.
Static files may also be cached thereby providing greater resiliency. Since the HTML response is generated in advance, the processing time on the server is negligible thereby resulting in a faster TTFB and better performance. In an ideal scenario, client-side JS should be minimal and static pages should become interactive soon after the response is received by the client. As a result, SSG helps to achieve a faster FCP/TTI.
### Basic Structure
As the name suggests, static rendering is ideal for static content, where the page need not be customized based on the logged-in user (e.g personalized recommendations). Thus static pages like the '_About us_', '_Contact us_', _Blog_ pages for websites or product pages for e-commerce apps, are ideal candidates for static rendering. Frameworks like Next.js, Gatsby, and VuePress support static generation.
**Next.js:**
```js
// pages/about.js
export default function About() {
return (
<div>
<h1>About Us</h1>
{/* ... */}
</div>
);
}
```
When the site is built (using `next build`), this page will be pre-rendered into an HTML file `about.html` accessible at the route `/about`.
### SSG with Data
Static content like that in 'About us' or 'Contact us' pages may be rendered as-is without getting data from a data-store. However, for content like individual blog pages or product pages, the data from a data-store has to be merged with a specific template and then rendered to HTML at build time.
#### Listing Page - All Items
In Next.js this can be achieved by exporting the function `getStaticProps()` in the page component. The function is called at build time on the build server to fetch the data.
```js
// This function runs at build time on the build server
export async function getStaticProps() {
return {
props: {
products: await getProductsFromDatabase(),
},
};
}
// The page component receives products prop from getStaticProps at build time
export default function Products({ products }) {
return (
<>
<h1>Products</h1>
<ul>
{products.map((product) => (
<li key={product.id}>{product.name}</li>
))}
</ul>
</>
);
}
```
The function will not be included in the client-side JS bundle and hence can even be used to fetch the data directly from a database.
#### Individual Details Page - Per Item
For individual details pages, we can use the function `getStaticPaths()` in combination with dynamic routes.
```js
// pages/products/[id].js
export async function getStaticPaths() {
const products = await getProductsFromDatabase();
const paths = products.map((product) => ({
params: { id: product.id },
}));
// fallback: false means pages that don't have the correct id will 404.
return { paths, fallback: false };
}
// params will contain the id for each generated page.
export async function getStaticProps({ params }) {
return {
props: {
product: await getProductFromDatabase(params.id),
},
};
}
export default function Product({ product }) {
// Render product
}
```
### SSG - Key Considerations
1. **A large number of HTML files:** Individual HTML files need to be generated for every possible route that the user may access. Maintaining a large number of HTML files can be challenging.
2. **Hosting Dependency:** For an SSG site to be super-fast and respond quickly, the hosting platform used to store and serve the HTML files should also be good. Superlative performance is possible if a well-tuned SSG website is hosted right on multiple CDNs to take advantage of edge-caching.
3. **Dynamic Content:** An SSG site needs to be built and re-deployed every time the content changes. The content displayed may be stale if the site has not been built + deployed after any content change. This makes SSG unsuitable for highly dynamic content.
## Source
- [patterns.dev/react/static-rendering](https://patterns.dev/react/static-rendering)
© patterns.dev · MIT · PatternsDev/skills