How to use the preact-render-to-string.default function in preact-render-to-string

To help you get started, we’ve selected a few preact-render-to-string examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SaraVieira / awesome-talks / src / index.js View on Github external
import App from './App'
import { render } from 'preact'
import { default as renderToString } from 'preact-render-to-string'
import { ServerStyleSheet } from 'styled-components'
import * as OfflinePluginRuntime from 'offline-plugin/runtime'

if (typeof window === 'undefined') {
  /* eslint-disable */
  const sheet = new ServerStyleSheet()
  const html = renderToString(sheet.collectStyles())
  const styleTags = sheet.getStyleTags()
  /* eslint-enable */
}
if (typeof window !== 'undefined') {
  render(, document.getElementById('root'))
  OfflinePluginRuntime.install()
}

preact-render-to-string

Render JSX to an HTML string, with support for Preact components.

MIT
Latest version published 3 days ago

Package Health Score

92 / 100
Full package analysis