Repository URL to install this package:
|
Version:
1.2.11 ▾
|
import React from 'react'
import { renderToStaticMarkup } from 'react-dom/server'
import { Response } from './typings'
import { ServerHTML } from './HTML'
export function renderWithoutServerSide(res: Response, nonce: string) {
if (process.env.DISABLE_SSR === 'true') {
console.log('[SSR] ==> Handling react route without SSR')
}
// SSR is disabled so we will return an "empty" html page and
// rely on the client to initialize and render the react application.
const html = renderToStaticMarkup(
<ServerHTML nonce={nonce} reactAppString="" styledTags={[]} />
)
res.status(200).send(`<!DOCTYPE html>${html}`)
res.end()
}