NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #3765 most downloaded on npm
Render JSX to an HTML string, with support for Preact components.
Last release 3 days ago
01 Oct 2026
Release timing varies
gaps range from 3 weeks to 7 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
124 releases · first in 2015
Updates peerDependencies to remove Preact 10 alpha versions, fixing unpkg issues
peerDependencies to remove Preact 10 alpha versions, fixing unpkg issues (#142)Add setState()/forceUpdate() no-op methods to prevent errors (#139, thanks @developit)
setState()/forceUpdate() no-op methods to prevent errors (#139, thanks @developit)preactjs [skip ci] (#138, thanks @mbrukman)One column per quarter.
Add package-lock for pika (#132, thanks @JoviDeCroock)
package-lock for pika (#132, thanks @JoviDeCroock)Fix support for default context value (#130, thanks @loklaan)
context value (#130, thanks @loklaan)strings (#129, thanks @sventschui)Fix exception when invoking setState in componentWillMount (#127, thanks @marvinhagemeister )
setState in componentWillMount (#127, thanks @marvinhagemeister )Fix effects breaking in SSR due to missing _renderCallbacks (#124, thanks @developit, @marvinhagemeister )
_renderCallbacks (#124, thanks @developit, @marvinhagemeister )pretty option (#123, thanks @dbushong)Add support for contextType for class components (#122, thanks @w4zZz4p)
contextType for class components (#122, thanks @w4zZz4p)Indent Fragment's children when pretty printing. (#117, thanks @utkarshkukreti)
Fragment's children when pretty printing. (#117, thanks @utkarshkukreti)state as an empty object (#119, thanks @marvinhagemeister)Fix each text node printed on a separate line. Adjacent text nodes are now combined together as a single text block. Note that you may need to update
preact-render-to-string with jest.Fix pretty option doing nothing (#106, thanks @marvinhagemeister)
pretty option doing nothing (#106, thanks @marvinhagemeister)options optional (#101, thanks @andrewiggins)Fix options.render is private in core (#97, thanks @marvinhagemeister)
options.render is private in core (#97, thanks @marvinhagemeister)Fragment to allow proper rendering (#96, thanks @toraora)Fix select value not passed through components (#85, thanks @marvinhagemeister)
createContext-API (#88, thanks @sventschui)mjs to js (#89, thanks @marvinhagemeister)Add support for Fragments (#79, thanks @marvinhagemeister)
Fragments (#79, thanks @marvinhagemeister)hooks (#77, thanks @vaneenige) 🎉Fixes hooks usage for SSR (#74, thanks @marvinhagemeister!)
This release contains only the backwards-incompatible changes necessary to move to Preact's new VNode format.
Support for Preact 10+.
This release contains only the backwards-incompatible changes necessary to move to Preact's new VNode format.
🎉 Adds support for getDerivedStateFromProps() (#63, thanks @johnhaitas!)
getDerivedStateFromProps() (#63, thanks @johnhaitas!)Update: 4.1.0 is now the official latest release (no longer a prerelease)!
Fix transpiled code for preact-render-to-string/jsx containing arrow functions in 4.0.0.
preact-render-to-string/jsx containing arrow functions in 4.0.0.The preact-render-to-string module no longer supports the { pretty: true } option. For this functionality, please migrate to preact-render-to-string/j
The preact-render-to-string module no longer supports the { pretty: true } option. For this functionality, please migrate to preact-render-to-string/jsx:
import renderToString from 'preact-render-to-string/jsx';
renderToString(<foo />, { pretty: true, jsx: false, xml: false });
Fix transpiled code for preact-render-to-string/jsx containing arrow functions in 3.8.1.
preact-render-to-string/jsx containing arrow functions in 3.8.1.Revert an unintentionally breaking change from 3.8.0 where undefined vnodes throw an exception. Expect this behavior in the future, but for now they w…
<undefined>. (#59 / #61, thanks @billneff79)defaultProps to work the same way it does in Preact on the client (#60, thanks @ftes)Drop support for Object class values (class={{ a: 1 }}), since they were removed from Preact in 8.x.
class={{ a: 1 }}), since they were removed from Preact in 8.x.Important update: Fixes an HTML injection vulnerability (CVE-2018-6341). See React's detailed notes.
Nothing published for this version
Add TypeScript definitions (#39, thanks @niedzielski)
true values like Preact's default renderer does (#48)dangerouslySetInnerHTML in JSX mode (#42, #46){nodeName:undefined} rendering [object Object] (#38, #47)Nothing published for this version
Fix JSX render indenting empty lines in Preact 8 (developit/preact-jsx-chai#46, thanks @aotarola!)
Prevent stateful re-rendering from being triggered during String rendering (developit/preact#524).
Add slashes to self-closing tags to support both XHTML and HTML (#25, thanks @elliotdavies!)
Add SVG xlink prop support with respect for foreignObject (thanks @wildlyinaccurate!)
xlink prop support with respect for foreignObject (thanks @wildlyinaccurate!)fix performance regression noticed by @lukeed
Add support for boolean attributes with empty string value (#17, thanks @wyze)
Don't render empty values as HTML comments (to match preact no longer doing so)
Fix issue with Preact 6.1+ and the JSX mode where object values for the class prop were serialized as objects instead of their normalized string form
class prop were serialized as objects instead of their normalized string formUpdate to preact 6.1 and fix class/className massaging, fix class being left as an Object due to changes in Preact 6.1.
class/className massaging, fix class being left as an Object due to changes in Preact 6.1.Add special treatment for style and class DOM attributes to match DOM renderer
style and class DOM attributes to match DOM rendererAdd support for disabling function and/or function name comparison in JSX mode
{ functionNames:false } just serializes all function props as prop={Function}{ functions:false } turns off function serialization entirelyskipFalseAttributes option - when set to false, turns off DOM attribute skipping (#4)Dont use self-closing tags in JSX mode
Fix JSX rendering being non-deterministic about empty VNodes
JSX Mode: skip attributes with null and undefined values
null and undefined valuesNothing published for this version
Nothing published for this version
> _TL;DR: 3.0.0's {jsx:true} option has been replaced with preact-render-to-string/jsx._
TL;DR: 3.0.0's
{jsx:true}option has been replaced withpreact-render-to-string/jsx.
3.0.0 added support for test-style JSX rendering (complex attributes rendered out using pretty-format). However, pretty-format actually doubled the size of preact-render-to-string and broke support for Node 4 and prior.
Instead of adding weight to the core library, which is often used in browsers (this library is part of preact-compat, for example), it's better to support these two "modes" via separate entrypoints into the module.
Here's the new solution - the library is now split into two different entrypoints, one for HTML/XML rendering, and the other specialized entry for JSX-style debug rendering.
import renderToString from 'preact-render-to-string';
import renderToString from 'preact-render-to-string/jsx';
Nothing published for this version
Add a { jsx:true } mode, which uses pretty-format to render complex JSX-style attribute values. This is useful for debugging purposes, and for preact-
{ jsx:true } mode, which uses pretty-format to render complex JSX-style attribute values. This is useful for debugging purposes, and for preact-jsx-chai> Preact 5.2+ started passing Object style props through to the DOM better rendering performance, but that broke renderToString(). This fixes it!
Preact 5.2+ started passing Object style props through to the DOM better rendering performance, but that broke
renderToString(). This fixes it!
componentWillMount() for stateful components just before render(). Thanks @mikestead!Add support for defaultProps on both pure and class components
defaultProps on both pure and class components (#5)Skip children, key and ref attributes when rendering to HTML.
children, key and ref attributes when rendering to HTML.Fix falsey and boolean attributes so they render properly in HTML and XML modes
Add support for a {pretty:true} option, which outputs formatting whitespace. This release is dedicated to @drastick for his tenure.
{pretty:true} option, which outputs formatting whitespace. This release is dedicated to @drastick for his tenure.prettyRender(
<section>
<a href="/foo">foo</a>
bar
<p>hello</p>
</section>
);
// output:
<section>
<a href="/foo">foo</a>
bar
<p>hello</p>
</section>
Generate globally unique common names for unnamed components, instead of falling back to "Component".
Generate globally unique common names for unnamed components, instead of falling back to "Component".
Unnamed components are now rendered as
<UnnamedComponent0>, where0is an internal ID. Two identical components (referentially equal) will render with the same name, useful for testing unnamed components.
Don't assume Function.prototype exists (it doesn't for ES2015 arrow functions)
Add a renderRootComponent:false option, which skips rendering for components located at the root of the given JSX tree.
Example:
render(<Foo>a</Foo>) === '<Foo>a</Foo>'
Add sortAttributes option. When set to true, attributes are sorted by name lexicographically during serialization. Useful for testing, such as via pre
sortAttributes option. When set to true, attributes are sorted by name lexicographically during serialization. Useful for testing, such as via preact-jsx-chaiDo not close void elements (#3 - thanks @i-like-robots!)
Bugfix: Falsey values (false, null and undefined) are no longer incorrectly rendered as strings (Issue #2)
false, null and undefined) are no longer incorrectly rendered as strings (Issue #2)Nothing published for this version
Breaking change: second argument to render() and shallowRender() is now context instead of options. options is now the third argument (see poll).
Breaking change: second argument to render() and shallowRender() is now context instead of options. options is now the third argument (see poll).
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Adds support for managing className VS class.
className VS class.
className takes precedence over classclass attributeYour coding agent can read these notes before it upgrades. Set up the MCP server →