-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[19] Add docs for prerender APIs #7320
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
0ee1b77
to
76a46c1
Compare
* **optional** `bootstrapModules`: Like `bootstrapScripts`, but emits [`<script type="module">`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) instead. | ||
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. Must be the same prefix as passed to [`hydrateRoot`.](/reference/react-dom/client/hydrateRoot#parameters) | ||
* **optional** `namespaceURI`: A string with the root [namespace URI](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS#important_namespace_uris) for the stream. Defaults to regular HTML. Pass `'http://www.w3.org/2000/svg'` for SVG or `'http://www.w3.org/1998/Math/MathML'` for MathML. | ||
* **optional** `onError`: A callback that fires whenever there is a server error, whether [recoverable](#recovering-from-errors-outside-the-shell) or [not.](#recovering-from-errors-inside-the-shell) By default, this only calls `console.error`. If you override it to [log crash reports,](#logging-crashes-on-the-server) make sure that you still call `console.error`. You can also use it to [adjust the status code](#setting-the-status-code) before the shell is emitted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call this an error during prerendering since it's not a server per se
async function renderToString() { | ||
const {prelude} = await prerender(<App />, { | ||
bootstrapScripts: ['/main.js'] | ||
}); | ||
|
||
const reader = stream.getReader(); | ||
let content = ''; | ||
while (true) { | ||
const {done, value} = await reader.read(); | ||
if (done) { | ||
return content; | ||
} | ||
content += Buffer.from(value).toString('utf8'); | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like you are mixing node and non node in this example.
async function renderToString() { | |
const {prelude} = await prerender(<App />, { | |
bootstrapScripts: ['/main.js'] | |
}); | |
const reader = stream.getReader(); | |
let content = ''; | |
while (true) { | |
const {done, value} = await reader.read(); | |
if (done) { | |
return content; | |
} | |
content += Buffer.from(value).toString('utf8'); | |
} | |
} | |
``` | |
async function renderToString() { | |
const {prelude} = await prerender(<App />, { | |
bootstrapScripts: ['/main.js'] | |
}); | |
const reader = stream.getReader(); | |
const decoder = new TextDecoder() | |
let content = ''; | |
while (true) { | |
const {done, value} = await reader.read(); | |
if (done) { | |
content += decoder.decode() | |
return content; | |
} | |
content += decoder.decode(value, { stream: true }); | |
} | |
} |
* Convert "Canary" callouts to "React 19 beta" (#6811) * Convert "Canary" callouts to "React 19 beta" * Starting in * Bump version string * Bump deploy * Bump deploy * Bump deploy * [19] Remove <NextMajor> callouts (#6844) * Remove <NextMajor> callouts * rm if(node) * Delete removed APIs from 19 docs (#6845) * Add information about ref handling in strict mode (#6777) * Add information about DOM ref handling in strict mode * switch order of ref object / ref callback in strictmode doc * use 'refs to components' terminology instead of 'DOM refs' * update references to canary/r19 * Expand usage example and remove badges --------- Co-authored-by: Rick Hanlon <rickhanlonii@fb.com> * [19] s/"Server Action"/"Server Function" (#7180) * [19] s/Server Action/Server Function * Revert /blog and change redirect * Add note * Tweak note * [v19] Update sandboxes to 19 RC (#7196) * Update transition docs for React 19 (#6837) * Add async transitions to React 19 docs * Updates from feedback * tweaks * grammar * Add startTranstion API * Apply suggestions from code review Co-authored-by: Noah Lemen <noah.lemen@gmail.com> * Updated * capitalization * grammar --------- Co-authored-by: Noah Lemen <noah.lemen@gmail.com> * [19] Add docs for prerender APIs (#7320) * Add prerender APIs * fix code blocks --------- Co-authored-by: Noah Lemen <noah.lemen@gmail.com>
No description provided.