Skip to content

Server side rendering  #2530

Closed
Closed

Description

@Vadorequest

Hello, I just opened a SO question about how to do SSR with create-react-app. I'm not particularly looking for SSR, maybe another solution would work for me. (Like templating, or variable injection)

https://stackoverflow.com/questions/44472024/how-to-use-server-side-rendering-with-create-react-app

Thanks.

Activity

  1. peterbe commented on Jun 15, 2017

    @peterbe

    What is the issue? How do you expect this to be actionable?

  2. Timer commented on Jun 15, 2017

    @Timer
    Contributor

    I'm going to close this because it seems you have answers on the SO question.
    However, the most relevant section of our docs is probably this.

  3. Vadorequest commented on Jun 15, 2017

    @Vadorequest
    Author

    @Timer Actually, there was no useful answer given on SO and my post got closed.

    I also think the data injection is the way to go, but I don't understand how it works, how do you set the __SERVER_DATA__ in the given example? There is a lot of things done under the hood and I don't quite understand how to implement it. But yeah, it would be enough for my needs actually, no need for SSR.

  4. Timer commented on Jun 15, 2017

    @Timer
    Contributor

    This section has a snippet about it:

    Then, on the server, regardless of the backend you use, you can read index.html into memory and replace __OG_TITLE__, __OG_DESCRIPTION__, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML!

    Basically, read index.html from the disk and replace it using your preferred method.

  5. Vadorequest commented on Jun 15, 2017

    @Vadorequest
    Author

    I use npm run start cli command to lift my dev server. This is all managed by react-scripts, how am I supposed to do this replace thing then? On production, I can probably do it after the npm run build, but I need an identical process between dev and prod. Maybe I'm missing something?

  6. Timer commented on Jun 15, 2017

    @Timer
    Contributor

    See #1703.

  7. leoskyrocker commented on Jul 10, 2017

    @leoskyrocker

    @Vadorequest not sure if this helps, but here's an example of how to do the server side templating: https://stackoverflow.com/a/38129612/2461213

  8. locked and limited conversation to collaborators on Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions