-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
renderToStaticMarkup is not allowed in Next.js 14 #57669
Comments
I think I've figured out the solution. Following code should work: export function renderToStaticMarkup(element: any) {
return new Promise((resolve, reject) => {
let html = '';
const writableStream = new Writable({
write(chunk: any, encoding: any, callback: any) {
html += chunk;
callback();
},
});
writableStream.on('finish', () => {
resolve(html);
});
writableStream.on('error', reject);
renderToPipeableStream(element).pipe(writableStream);
});
} |
Can you please publish a codesandbox example, I still can't get it to work (even with your renderToPipeableStream code). Thanks. |
@hughlv Could you provide the sandbox with the solution, please ? |
Can you let me know if this issue has been resolved? please answer.. thank you |
I'm using Am I screwed in Next 14? |
i don't think the solution posted is a solution at all, really. it's suggesting to make a local version of the API that internally uses another API, and that doesn't feel like the right way to go about this. can this be re-opened and someone explain the reason for this error, when it doesn't look from react's documentation that the API's legacy/deprecated at all? ref |
Hey! @opeologist @mattiaz9 @kindunq @poorscousertommy8 and others, let's continue searching the help in this discussion - [Next.js 14 / React 18] How to migrate from renderToStaticMarkup method on the Client side? Could you tap the |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/busy-bohr-xyz6rn?file=%2Fapp%2Fpage.tsx%3A15%2C1
To Reproduce
The issue is quite straightforward.
In certain case I need to generate static HTML code with
renderToStaticMarkup
, which works fine even in the last canary build of Nextjs 13.5.7-canary.14, but in v14 I will receive following errors.This is a simplified verison of code so please don't bother why not return the div code direclty.
Error info:
I did a research on both GitHub and Vercel website but did not find a clue of the solution. In React, this funciton is not marked as deprecated.
Please advice what to do with this problem. Thanks.
Current vs. Expected behavior
I expected to use renderToStaticMarkup normally.
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.1.0: Tue Sep 26 22:11:17 PDT 2023; root:xnu-10002.40.89.501.1~3/RELEASE_ARM64_T8103 Binaries: Node: 19.9.0 npm: 9.6.3 Yarn: 1.22.18 pnpm: 8.9.0 Relevant Packages: next: 14.0.0 eslint-config-next: 14.0.0 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Additional context
No response
The text was updated successfully, but these errors were encountered: