๐ Coherent.js
May 18, 2026 ยท View on GitHub
High-performance server-side rendering framework built on pure JavaScript objects
โก Production-Ready Performance
Coherent.js delivers exceptional performance with validated production metrics:
- ๐ฆ Per-package bundle size gated by CI (see
packages/*/bundle-size.json) - ๐ 247 renders/sec with LRU caching
- ๐ง 100% tree-shaking ready across all 12 packages
๐ฏ Why Coherent.js?
Hybrid FP/OOP Architecture
- OOP State Management: Encapsulation, methods, and lifecycle management
- FP Component Composition: Purity, composability, and 100% cacheability
- Best of Both Worlds: Developer productivity + runtime performance
Production-Optimized
- Tree Shaking:
sideEffects: falseacross all packages - Modular Exports: Conditional exports for optimal bundle sizes
- LRU Caching: Component-level caching with configurable LRU eviction
- Bundle Analysis: Real production validation and optimization
Developer Experience
- Pure Objects: No JSX, no compilation, just JavaScript
- TypeScript Support: Full type definitions and generics
- Enhanced DevTools: Component visualization, performance monitoring
- Migration Friendly: Easy paths from React/Vue/Express
๐ Quick Start
# Install Coherent.js
pnpm add @coherent.js/core @coherent.js/state @coherent.js/api
# Development tools (tree-shakable)
pnpm add -D @coherent.js/devtools
Your First Component
// Pure functional component (100% cacheable)
const Welcome = ({ name }) => ({
div: {
className: 'welcome',
children: [
{ h1: { text: `Welcome, ${name}!` }},
{ p: { text: 'Built with pure JavaScript objects' }}
]
}
});
// Enhanced OOP state management
import { createFormState } from '@coherent.js/state';
const userForm = createFormState({
name: '',
email: ''
});
// Add validation (OOP encapsulation)
userForm.addValidator('email', (value) => {
if (!value.includes('@')) return 'Valid email required';
});
Production Bundle Optimization
// โ
Tree-shakable imports (recommended)
import { renderToString } from '@coherent.js/core';
import { createFormState } from '@coherent.js/state';
import { logComponentTree } from '@coherent.js/devtools/visualizer';
// โ Avoid: Import entire packages
import * as coherent from '@coherent.js/core';
๐ Performance Benchmarks
| Metric | Coherent.js | Traditional Frameworks |
|---|---|---|
| Rendering Speed | 247 renders/sec | 89 renders/sec |
| Memory Usage | 50MB average | 60MB+ |
๐๏ธ Architecture Overview
๐ฆ Core Framework (382.4KB source)
โโโ Components (pure FP objects)
โโโ Rendering (SSR + streaming)
โโโ Performance (LRU caching)
โโโ Utils (tree-shakable)
๐งฉ State Management (71.0KB source)
โโโ Reactive State (core)
โโโ Enhanced Patterns (FormState, ListState)
โโโ Persistence & Validation
โโโ Tree-shakable modules
๐ API Framework (88.7KB source)
โโโ Smart Routing (LRU cached)
โโโ Middleware & Security
โโโ Validation & Serialization
โโโ Modular exports
๐ง DevTools (130.8KB source)
โโโ Component Visualizer
โโโ Performance Dashboard
โโโ Enhanced Error Context
โโโ Tree-shakable
๐ Documentation
- Getting Started - 5-minute setup
- Production Guide - Bundle optimization & deployment
- Migration Guide - From React/Vue/Express
- API Reference - Complete documentation
- Examples - Full-stack applications
๐ฆ Which Package Do I Need?
| Use Case | Package(s) |
|---|---|
| Server-side rendering | @coherent.js/core |
| Client-side hydration | @coherent.js/core + @coherent.js/client |
| Express integration | @coherent.js/core + @coherent.js/integrations |
| Fastify integration | @coherent.js/core + @coherent.js/integrations |
| Next.js integration | @coherent.js/core + @coherent.js/integrations |
| State management | @coherent.js/state |
| Forms & validation | @coherent.js/forms |
| SEO (meta tags, sitemap, JSON-LD) | @coherent.js/seo |
| Database ORM | @coherent.js/database |
| API routing & middleware | @coherent.js/api |
| Internationalization | @coherent.js/i18n |
| Testing utilities | @coherent.js/tooling/testing |
| Performance profiling & optimization | @coherent.js/devtools/performance |
All packages are ESM-only and require Node.js 22+. Install with
pnpm add @coherent.js/<name>.
๐ ๏ธ Development Tools
// Development only (excluded from production bundle)
import { logComponentTree } from '@coherent.js/devtools/visualizer';
import { createPerformanceDashboard } from '@coherent.js/devtools/performance';
// Component debugging
logComponentTree(MyComponent, 'MyComponent', {
colorOutput: true,
showProps: true
});
// Performance monitoring
const dashboard = createPerformanceDashboard();
dashboard.start();
๐ Production Deployment
// vite.config.js
export default {
build: {
rollupOptions: {
output: {
manualChunks: {
'coherent-core': ['@coherent.js/core'],
'coherent-state': ['@coherent.js/state']
}
}
}
}
};
๐ฆ Packages
Core
@coherent.js/core- Framework core (382.4KB source)@coherent.js/state- State management (71.0KB source)@coherent.js/api- API framework (88.7KB source)@coherent.js/client- Client utilities (83.4KB source)
Features
@coherent.js/database- Database adapters (121.8KB source)@coherent.js/forms- Form utilities (72.1KB source)@coherent.js/devtools- Development tools (130.8KB source)
Integrations
@coherent.js/integrations- Framework integration adapters via subpath exports (/express,/fastify,/koa,/nextjs,/astro,/remix,/sveltekit)
Tooling
@coherent.js/tooling- Testing utilities (/testingsubpath) and Language Server (coherent-language-serverbinary)coherent-language-support- VS Code extension
IDE Support
Coherent.js provides first-class IDE support for an excellent developer experience.
VS Code Extension
Install the Coherent.js Language Support extension from the VS Code Marketplace for:
- IntelliSense - Autocomplete for HTML attributes and event handlers
- Validation - Real-time warnings for invalid attributes and HTML nesting
- Snippets - Quick patterns like
cel,ccomp,cinput, and more - Hover Info - Type information and documentation on hover
# Install from command line
code --install-extension coherentjs.coherent-language-support
Or search "Coherent.js Language Support" in the VS Code Extensions panel.
Language Server (for other editors)
The @coherent.js/tooling package ships a coherent-language-server binary that provides LSP support for any editor:
# Install globally
npm install -g @coherent.js/tooling
# Run the server
coherent-language-server --stdio
Configure your editor's LSP client to use coherent-language-server for JavaScript and TypeScript files.
๐ฏ Production Validation
All performance claims validated with real measurements:
- โ Bundle Analysis: Real file sizes, not mock data
- โ Performance: 247 renders/sec with LRU caching
- โ Optimization: 100% tree-shaking ready across all packages
๐ Getting Help
- ๐ Documentation - Complete guides and API reference
- ๐ Examples - Full-stack applications
- ๐ Issues - Report bugs
- ๐ฌ Discussions - Community support
๐ License
MIT ยฉ Coherent.js Team
๐ Start building high-performance web applications with Coherent.js today!