exact

raw JSON →
1.0.1 verified Sat Apr 25 auth: no javascript

exact is a universal React framework for building web applications with support for both server-side rendering (SSR) and static site generation (SSG). The current stable version is 1.0.1 (August 2024), with monthly releases. It differentiates itself from Next.js by offering a minimal, framework-agnostic approach with zero configuration, automatic code splitting, and built-in TypeScript support. The package was originally a different utility (v0.x) but was renamed for the React framework. It is designed for modern React development with ESM and CommonJS support.

error Module not found: Can't resolve 'exact'
cause Package not installed or version <1.0.0 (old package).
fix
Run 'npm install exact@1.0.1' and ensure import path is correct.
error TypeError: exact.createServer is not a function
cause Using default import but the function is not exported as default.
fix
Use named import: import { createServer } from 'exact'.
error SyntaxError: Cannot use import statement outside a module
cause Running ESM code in a CommonJS module.
fix
Add 'type': 'module' in package.json or use .mjs extension.
breaking The package was renamed from v0.x (a different utility) to v1.0 (React framework). All APIs changed.
fix Update to v1.0 and rewrite code using the new React framework APIs.
deprecated CommonJS require() may be deprecated in future versions. Use ESM imports.
fix Use import instead of require.
gotcha Automatic code splitting requires dynamic import() syntax. Static imports will bundle all code.
fix Use dynamic import() for route-based code splitting.
gotcha Server-side rendering requires Node.js 14 or higher.
fix Upgrade Node.js to version 14+ or use static export.
npm install exact
yarn add exact
pnpm add exact

Creates a basic server that renders a React component to string using exact.createServer.

import exact from 'exact';
import React from 'react';

const App = () => <h1>Hello, Exact!</h1>;

const server = exact.createServer({ port: 3000 });
server.renderToString(<App />).then(html => {
  console.log(html);
});