High Performance
Repository benchmark snapshots currently average 2.078ms for 1000 flat blocks and 20.641ms for 10000 flat blocks.
Audited block conversion for modern WordPress content with hydration, SSR helpers, and WordPress 6.9 compatibility coverage.
WP Block to HTML is published on NPM with a compatibility-first release track focused on truthful support statements and modern WordPress coverage.
npm install wp-block-to-htmlWP Block to HTML is a production-ready JavaScript library that converts WordPress block data into clean, framework-agnostic HTML. It bridges the gap between WordPress as a content management system and modern frontend applications built with frameworks like React, Vue, Next.js, or any other technology.
import { convertBlocks } from 'wp-block-to-html';
// WordPress blocks data
const blocks = [
{
blockName: 'core/paragraph',
attrs: { content: 'Hello World', align: 'center' },
innerBlocks: []
}
];
// Convert to HTML
const html = convertBlocks(blocks);
console.log(html); // <p class="has-text-align-center">Hello World</p>| Version | Status | Notes |
|---|---|---|
6.8 | Supported | Stable baseline |
6.9 | Supported | Includes core/math, core/accordion, core/latest-comments, core/terms-query, core/comments-link, and core/comments-count |
7.0 beta/RC | Partial | Adds core/breadcrumbs plus metadata.blockVisibility compatibility hooks; broader theme/query/navigation parity is still deferred |
The published package includes client-side hydration capabilities for SSR scenarios:
import { HydrationManager } from 'wp-block-to-html/hydration';
// Progressive hydration with multiple strategies
const hydrationManager = new HydrationManager({
strategy: 'viewport', // viewport, interaction, idle, immediate
rootSelector: '#app'
});
// Hydrate specific blocks
await hydrationManager.hydrateBlock('block-id-123');
// Batch hydration
await hydrationManager.hydrateAll();Easily integrate with popular JavaScript frameworks:
// React Integration
import { createReactComponent } from 'wp-block-to-html/react';
const BlockComponent = createReactComponent(blocks, {
cssFramework: 'tailwind',
hydration: { strategy: 'viewport' }
});
// Vue Integration
import { createVueComponent } from 'wp-block-to-html/vue';
const BlockComponent = createVueComponent(blocks, {
cssFramework: 'bootstrap',
hydration: { strategy: 'interaction' }
});Generate HTML with classes from your preferred CSS framework:
// Using Tailwind CSS
const html = convertBlocks(blocks, {
cssFramework: 'tailwind'
});
// Using Bootstrap
const html = convertBlocks(blocks, {
cssFramework: 'bootstrap'
});
// Using custom class mappings
const html = convertBlocks(blocks, {
cssFramework: 'custom',
customClassMap
});Optimize your content for better performance metrics:
// Apply SSR optimizations
const html = convertBlocks(blocks, {
ssrOptions: {
enabled: true,
optimizationLevel: 'maximum',
lazyLoadMedia: true
},
hydration: {
strategy: 'progressive',
priorityBlocks: ['core/button', 'core/gallery']
}
});1000 blocks average 2.078ms10000 blocks average 20.641msnone 1.601ms, tailwind 2.029ms, bootstrap 1.308ms for 1000 blocks# Install the stable release
npm install wp-block-to-html
# Or using yarn
yarn add wp-block-to-html
# Or using pnpm
pnpm add wp-block-to-htmlWP Block to HTML is licensed under the MIT License.