You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am looking for an approach to migrate from rails templates to nextjs smoothly. In my particular case I have a e-commerce rails application with server rendering via erb templates. We would like to migrate to nextjs, but we can't stop implementation just to focus on code rewriting, and also we can't migrate page by page because they are too huge. So I am looking for a way to start migration piece by piece.
My general idea is the following - I rewrite some piece of page from erb template to react+nextjs and then I want to use nextjs as an ssr engine. The migrated component I make a nextjs page and inside rails I make fetch request to that nextjs application by the component route, nextjs renders the react component and returns html string and I insert that html back in erb template as raw html and then rails sends the final html to client.
By that I will be able to migrate from erb templates to nextjs step by step, without whole page rewriting which could take a while.
However, there are some question how to implement this approach.
How to make nextjs to avoid requiring root layout tags
I have Error: Missing <html> and <body> tags in the root layout. error
Probably I need to make the route response to be not an html but an json object with two fields: content - the result html, assets - the script and css tags
How to make nextjs to hydrate not from the root document, but by special html tag reference, similar to react's core api
Maybe some other ideas/advices on migration to nextjs piece by piece?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hello, I am looking for an approach to migrate from rails templates to nextjs smoothly. In my particular case I have a e-commerce rails application with server rendering via erb templates. We would like to migrate to nextjs, but we can't stop implementation just to focus on code rewriting, and also we can't migrate page by page because they are too huge. So I am looking for a way to start migration piece by piece.
My general idea is the following - I rewrite some piece of page from erb template to react+nextjs and then I want to use nextjs as an ssr engine. The migrated component I make a nextjs page and inside rails I make fetch request to that nextjs application by the component route, nextjs renders the react component and returns html string and I insert that html back in erb template as raw html and then rails sends the final html to client.
By that I will be able to migrate from erb templates to nextjs step by step, without whole page rewriting which could take a while.
However, there are some question how to implement this approach.
I have
Error: Missing <html> and <body> tags in the root layout.
errorMaybe some other ideas/advices on migration to nextjs piece by piece?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions