{"library":"react-snap","title":"Zero-Configuration Static Prerendering for SPAs","description":"react-snap is a zero-configuration, framework-agnostic static prerendering tool designed to convert Single Page Applications (SPAs) into static HTML. It leverages Headless Chrome (powered by Puppeteer) to crawl all navigable links from a given root, effectively generating static HTML files. This process significantly enhances SEO and initial page load performance by delivering pre-rendered content to the browser before JavaScript execution. The package is currently at version 1.23.0 and appears to be in a maintenance phase rather than active feature development, with its last major release dating back to early 2020. A key differentiator is its out-of-the-box compatibility with tools like Create React App and its ability to handle modern browser features without issue, as it uses a real browser for rendering. It primarily operates as a `postbuild` script, integrating into existing build workflows without requiring direct programmatic imports into the application's source code.","language":"javascript","status":"maintenance","last_verified":"Tue Apr 21","install":{"commands":["npm install react-snap"],"cli":{"name":"react-snap","version":null}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"yarn add --dev react-snap\n\n// package.json\n// ...\n// \"scripts\": {\n//   \"build\": \"react-scripts build\",\n//   \"postbuild\": \"react-snap\"\n// }\n// ...\n\n// src/index.js (for React 16+)\nimport { hydrate, render } from \"react-dom\";\nimport App from \"./App\"; // Assuming your main App component\n\nconst rootElement = document.getElementById(\"root\");\nif (rootElement.hasChildNodes()) {\n  hydrate(<App />, rootElement);\n} else {\n  render(<App />, rootElement);\n}\n","lang":"javascript","description":"Demonstrates how to integrate react-snap into a Create React App project by adding it as a dev dependency, configuring a post-build script, and updating the React root rendering logic for proper hydration.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}