{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/1979","labels_url":"https://api.github.com/repos/facebook/react/issues/1979/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/1979/comments","events_url":"https://api.github.com/repos/facebook/react/issues/1979/events","html_url":"https://github.com/facebook/react/issues/1979","id":39357527,"number":1979,"title":"Server-rendering should be distinct from client-rendering","user":{"login":"syranide","id":1714255,"avatar_url":"https://avatars.githubusercontent.com/u/1714255?v=3","gravatar_id":"","url":"https://api.github.com/users/syranide","html_url":"https://github.com/syranide","followers_url":"https://api.github.com/users/syranide/followers","following_url":"https://api.github.com/users/syranide/following{/other_user}","gists_url":"https://api.github.com/users/syranide/gists{/gist_id}","starred_url":"https://api.github.com/users/syranide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syranide/subscriptions","organizations_url":"https://api.github.com/users/syranide/orgs","repos_url":"https://api.github.com/users/syranide/repos","events_url":"https://api.github.com/users/syranide/events{/privacy}","received_events_url":"https://api.github.com/users/syranide/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2014-08-02T21:20:15Z","updated_at":"2015-06-21T23:36:15Z","closed_at":null,"body":"Kind of related to #1978 (concerns polyfills)\r\n\r\nIt seems to me that we should really treat server-rendering as distinct from client-rendering, they have different requirements and priorities.\r\n\r\n1. Server-rendering should be able to generate optimal markup for SEO, markup must also be fully cross-browser compatible and small markup is preferable.\r\n\r\n2. Client-rendering sees SEO as largely irrelevant, full cross-browser compatibility is also irrelevant and rendering performance is of greater importance.\r\n\r\nSo I propose that we treat server-rendering as uniquely distinct from client-rendering, e.g. as a separate flag`React.serverSide = true` (which would default to true if document is not available). It's even imaginable that we could extend this with e.g. `React.targetClient = 'SEO' / 'legacyClient' / 'everGreenClient'`, which would optionally allow the markup to be tailored for a specific purpose.\r\n\r\nSo when reusing server-rendered markup client-side:\r\n\r\n1. The client should do an initial server-rendering pass being passed the exact same props (and time) as during the server-side rendering, but instances are actually allocated on the client.\r\n\r\n2. Immediately afterwards a client-rendering pass is done with any props (and current time) you like, instances/markup is efficiently reused and should not add significant costs as little DOM manipulation should be involved.\r\n\r\nI'm not really affected by this, but for those that do use server-rendering; this seems like the *correct* way of approaching it (as opposed to just rendering everything exactly the same). However, I'm working on `img`- and `picture`-element polyfills, but without this they cannot be made to generate sensible server-side markup.\r\n\r\n**PS. I realize this can be done today using a global + mixin**, but without a standardized solution, it's unlikely that third-party (and polyfill) components could ever participate in this. But that doesn't mean that it needs to be shipped with React even (none of this requires core support I believe), as long as it's standardized."},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/113968856","html_url":"https://github.com/facebook/react/issues/1979#issuecomment-113968856","issue_url":"https://api.github.com/repos/facebook/react/issues/1979","id":113968856,"user":{"login":"spicyj","id":6820,"avatar_url":"https://avatars.githubusercontent.com/u/6820?v=3","gravatar_id":"","url":"https://api.github.com/users/spicyj","html_url":"https://github.com/spicyj","followers_url":"https://api.github.com/users/spicyj/followers","following_url":"https://api.github.com/users/spicyj/following{/other_user}","gists_url":"https://api.github.com/users/spicyj/gists{/gist_id}","starred_url":"https://api.github.com/users/spicyj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spicyj/subscriptions","organizations_url":"https://api.github.com/users/spicyj/orgs","repos_url":"https://api.github.com/users/spicyj/repos","events_url":"https://api.github.com/users/spicyj/events{/privacy}","received_events_url":"https://api.github.com/users/spicyj/received_events","type":"User","site_admin":false},"created_at":"2015-06-21T23:36:15Z","updated_at":"2015-06-21T23:36:15Z","body":"You should be able to do this with context fairly easily in 0.14."}}