@coherent.js/express
v1.0.0-beta.5
Published
Express adapter for Coherent.js
Readme
@coherent.js/express
Express adapter for Coherent.js.
- ESM-only, Node 20+
- Works with
[email protected] - Designed to pair with
@coherent.js/core
For a high-level overview and repository-wide instructions, see the root README: ../../README.md
Installation
pnpm add @coherent.js/express express @coherent.js/corePeer dependencies:
express>= 4.18 < 6@coherent.js/core
Exports
Express.js adapter for Coherent.js
Modular Imports (Tree-Shakable)
- Express integration:
@coherent.js/express - Middleware setup:
@coherent.js/express
Example Usage
import { setupCoherent } from '@coherent.js/express';
import { renderComponent } from '@coherent.js/express';Note: All exports are tree-shakable. Import only what you need for optimal bundle size.
Quick start
You can use @coherent.js/core rendering inside Express handlers.
JavaScript (ESM):
import express from 'express';
import { renderToString } from '@coherent.js/core';
const app = express();
app.get('/', async (_req, res) => {
const html = await renderToString({ div: { text: 'Hello from Express + Coherent' } });
res.type('html').send(html);
});
app.listen(3000, () => console.log('http://localhost:3000'));TypeScript:
import express, { Request, Response } from 'express';
import { renderToString } from '@coherent.js/core';
const app = express();
app.get('/', async (_req: Request, res: Response) => {
const html = await renderToString({ div: { text: 'Hello TS' } });
res.type('html').send(html);
});
app.listen(3000);Development
pnpm --filter @coherent.js/express run test
pnpm --filter @coherent.js/express run test:watch
pnpm --filter @coherent.js/express run typecheck
pnpm --filter @coherent.js/express run buildLicense
MIT © Coherent.js Team
