![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
hyperapp-render
Advanced tools
Render Hyperapp to an HTML string with SSR and Node.js streaming support
This library is allowing you to render Hyperapp views to an HTML string.
Our first example is an interactive app from which you can generate an HTML markup. Go ahead and try it online.
import { h } from 'hyperapp'
import { renderToString } from 'hyperapp-render'
const state = {
text: 'Hello'
}
const actions = {
setText: text => ({ text })
}
const view = (state, actions) => (
<main>
<h1>{state.text.trim() === '' ? '👋' : state.text}</h1>
<input value={state.text} oninput={e => actions.setText(e.target.value)} />
</main>
)
const html = renderToString(view(state, actions))
console.log(html) // => <main><h1>Hello</h1><input value="Hello"/></main>
Looking for a boilerplate? Try Hyperapp Starter with pre-configured server-side rendering and many more.
Using npm:
npm install hyperapp-render --save
Or using a CDN like unpkg.com or jsDelivr with the following script tag:
<script src="https://unpkg.com/hyperapp-render"></script>
You can find the library in window.hyperappRender
.
We support all ES5-compliant browsers, including Internet Explorer 9 and above,
but depending on your target browsers you may need to include
polyfills for
Set
and
Map
before any other code.
The library provides two functions which you can use depending on your needs or personal preferences:
import { renderToString, renderToStream } from 'hyperapp-render'
renderToString(<Component />) // => <string>
renderToString(view(state, actions)) // => <string>
renderToString(view, state, actions) // => <string>
renderToStream(<Component />) // => <stream.Readable> => <string>
renderToStream(view(state, actions)) // => <stream.Readable> => <string>
renderToStream(view, state, actions) // => <stream.Readable> => <string>
Note: renderToStream
is available from
Node.js environment only (v6 or newer).
You can use renderToString
function to generate HTML on the server
and send the markup down on the initial request for faster page loads
and to allow search engines to crawl your pages for
SEO purposes.
If you call hyperapp.app()
on a node that already has this server-rendered markup,
Hyperapp will preserve it and only attach event handlers, allowing you
to have a very performant first-load experience.
The renderToStream
function returns a
Readable stream
that outputs an HTML string.
The HTML output by this stream is exactly equal to what renderToString
would return.
By using this function you can reduce TTFB
and improve user experience even more.
The library automatically escapes text content and attribute values of virtual DOM nodes to protect your application against XSS attacks. However, it is not safe to allow "user input" for node names or attribute keys:
const Node = 'div onclick="alert()"'
renderToString(<Node title="XSS">Hi</Node>)
// => <div onclick="alert()" title="XSS">Hi</div>
const attributes = { 'onclick="alert()" title': 'XSS' }
renderToString(<div {...attributes}>Hi</div>)
// => <div onclick="alert()" title="XSS">Hi</div>
const userInput = '<script>alert()</script>'
renderToString(<div title="XSS" innerHTML={userInput}>Hi</div>)
// => <div title="XSS"><script>alert()</script></div>
Hyperapp Render is MIT licensed. See LICENSE.
[4.0.1] - 2022-06-29
FAQs
Render Hyperapp to an HTML string with SSR and Node.js streaming support
The npm package hyperapp-render receives a total of 57 weekly downloads. As such, hyperapp-render popularity was classified as not popular.
We found that hyperapp-render demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.