{"action":"created","comment":{"url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/comments/48447336","id":48447336,"diff_hunk":"@@ -98,3 +100,63 @@ if (Meteor.isClient) {\n   ga('send', 'pageview');\n }\n ```\n+\n+## Example with Redux\n+\n+ReactRouterSSR supports applications that use Redux, using the `createReduxStore` and `wrapper` options in both clientOptions and serverOptions. \n+- `createReduxStore` should be a callback in the shape `(initialState, history) => store`\n+- `wrapper` should be the `Provider` component from react-redux (or some custom component wrapping the `Provider` and passing it the `store` prop it receives) \n+\n+On both server and client side, ReactRouterSSR.Run() takes care of calling the `createReduxStore` callback and passing the resulting store as a prop to the `wrapper` component.\n+\n+```javascript\n+import { Provider } from 'react-redux'\n+import createStore from './myAppStore'\n+\n+const {IndexRoute, Route} = ReactRouter;\n+\n+AppRoutes = (\n+  <Route path=\"/\" component={App}>\n+    <IndexRoute component={HomePage} />\n+    <Route path=\"login\" component={LoginPage} />\n+    <Route path=\"*\" component={NotFoundPage} />\n+    {/* ... */}\n+  </Route>\n+);\n+\n+Meteor.startup(() => {\n+  const clientOptions = {\n+    wrapper: Provider,\n+    createReduxStore: (initialState, history) => {\n+      const store = createStore(initialState);\n+      // If using redux-simple-router, this is where you can bind the history with syncReduxAndRouter\n+      syncReduxAndRouter(history, store);\n+      return store;\n+    }\n+  });","path":"README.md","position":53,"original_position":53,"commit_id":"769d75d7d4d73044982f92474cd4748c07360dbc","original_commit_id":"769d75d7d4d73044982f92474cd4748c07360dbc","user":{"login":"eXon","id":280982,"avatar_url":"https://avatars.githubusercontent.com/u/280982?v=3","gravatar_id":"","url":"https://api.github.com/users/eXon","html_url":"https://github.com/eXon","followers_url":"https://api.github.com/users/eXon/followers","following_url":"https://api.github.com/users/eXon/following{/other_user}","gists_url":"https://api.github.com/users/eXon/gists{/gist_id}","starred_url":"https://api.github.com/users/eXon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eXon/subscriptions","organizations_url":"https://api.github.com/users/eXon/orgs","repos_url":"https://api.github.com/users/eXon/repos","events_url":"https://api.github.com/users/eXon/events{/privacy}","received_events_url":"https://api.github.com/users/eXon/received_events","type":"User","site_admin":false},"body":"Their is a parenthesis here that shouldn't be","created_at":"2015-12-26T14:03:31Z","updated_at":"2015-12-26T14:03:31Z","html_url":"https://github.com/thereactivestack/meteor-react-router-ssr/pull/24#discussion_r48447336","pull_request_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/comments/48447336"},"html":{"href":"https://github.com/thereactivestack/meteor-react-router-ssr/pull/24#discussion_r48447336"},"pull_request":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/24","id":54463144,"html_url":"https://github.com/thereactivestack/meteor-react-router-ssr/pull/24","diff_url":"https://github.com/thereactivestack/meteor-react-router-ssr/pull/24.diff","patch_url":"https://github.com/thereactivestack/meteor-react-router-ssr/pull/24.patch","issue_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/issues/24","number":24,"state":"open","locked":false,"title":"Redux integration","user":{"login":"yched","id":193080,"avatar_url":"https://avatars.githubusercontent.com/u/193080?v=3","gravatar_id":"","url":"https://api.github.com/users/yched","html_url":"https://github.com/yched","followers_url":"https://api.github.com/users/yched/followers","following_url":"https://api.github.com/users/yched/following{/other_user}","gists_url":"https://api.github.com/users/yched/gists{/gist_id}","starred_url":"https://api.github.com/users/yched/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yched/subscriptions","organizations_url":"https://api.github.com/users/yched/orgs","repos_url":"https://api.github.com/users/yched/repos","events_url":"https://api.github.com/users/yched/events{/privacy}","received_events_url":"https://api.github.com/users/yched/received_events","type":"User","site_admin":false},"body":"As per the discussion in https://github.com/thereactivestack/kickstart-hugeapp/issues/27, here's a proposal for optional redux support :\r\n\r\nUsage : \r\nBehavior is triggered by a 'createReduxStore' callback in clientOptions / serverOptions.\r\nA 'wrapper' is also required, and it should be the react-redux `<Provider>` (or some custom component wrapping it)\r\n\r\n```js\r\nimport { Provider } from 'react-redux'\r\nimport routes from './myAppRoutes'\r\nimport createStore from './myAppStore'\r\n\r\nMeteor.startup(() => {\r\n  const clientOptions = {\r\n    wrapper: Provider, // Or some custom Component wrapping the redux Provider\r\n    createReduxStore: (initialState, history) => {\r\n      const store = createStore(initialState);\r\n      // If using redux-simple-router, this is where you can bind the history with syncReduxAndRouter\r\n      syncReduxAndRouter(history, store);\r\n      return store;\r\n    }\r\n  });\r\n  // Use the same 'wrapper' and 'createReduxStore' in serverOptions, or adjust to your needs.\r\n  const serverOptions = clientOptions;\r\n  ReactRouterSSR.Run(routes, clientOptions, serverOptions);\r\n});\r\n```\r\n\r\nIn detail, if options.createReduxStore callback is set :\r\n\r\nOn the server :\r\n- After route is resolved and before rendering\r\n  - create the store, passing a history to let the callback bind with redux-simple-router if it needs to\r\n  - allow data fetching : let the components for the route fire actions (possibly async / Promise-based) to populate the store, and wait for them to be done.\r\n    (see bottom of http://rackt.org/redux/docs/recipes/ServerRendering.html - implementation is inspired from https://github.com/erikras/react-redux-universal-hot-example)\r\n  - pass the store as a prop to the wrapper component (the redux `<Provider>`)\r\n- After rendering,\r\n  - grab the resulting store state and pass it in the HTML (using meteorhacks:inject-data)\r\n\r\nOn the client :\r\n- Before rendering \r\n  - create the store with the initial state populated from the server (if any)\r\n  - pass the store as a prop to the wrapper component (the redux `<Provider>`)\r\n\r\n","created_at":"2015-12-23T11:59:31Z","updated_at":"2015-12-26T14:03:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"706f24b9eab5a4421fc5de4bf266957b09bc74ed","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/24/commits","review_comments_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/24/comments","review_comment_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/issues/24/comments","statuses_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/statuses/769d75d7d4d73044982f92474cd4748c07360dbc","head":{"label":"yched:redux-integration","ref":"redux-integration","sha":"769d75d7d4d73044982f92474cd4748c07360dbc","user":{"login":"yched","id":193080,"avatar_url":"https://avatars.githubusercontent.com/u/193080?v=3","gravatar_id":"","url":"https://api.github.com/users/yched","html_url":"https://github.com/yched","followers_url":"https://api.github.com/users/yched/followers","following_url":"https://api.github.com/users/yched/following{/other_user}","gists_url":"https://api.github.com/users/yched/gists{/gist_id}","starred_url":"https://api.github.com/users/yched/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yched/subscriptions","organizations_url":"https://api.github.com/users/yched/orgs","repos_url":"https://api.github.com/users/yched/repos","events_url":"https://api.github.com/users/yched/events{/privacy}","received_events_url":"https://api.github.com/users/yched/received_events","type":"User","site_admin":false},"repo":{"id":48442576,"name":"meteor-react-router-ssr","full_name":"yched/meteor-react-router-ssr","owner":{"login":"yched","id":193080,"avatar_url":"https://avatars.githubusercontent.com/u/193080?v=3","gravatar_id":"","url":"https://api.github.com/users/yched","html_url":"https://github.com/yched","followers_url":"https://api.github.com/users/yched/followers","following_url":"https://api.github.com/users/yched/following{/other_user}","gists_url":"https://api.github.com/users/yched/gists{/gist_id}","starred_url":"https://api.github.com/users/yched/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yched/subscriptions","organizations_url":"https://api.github.com/users/yched/orgs","repos_url":"https://api.github.com/users/yched/repos","events_url":"https://api.github.com/users/yched/events{/privacy}","received_events_url":"https://api.github.com/users/yched/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yched/meteor-react-router-ssr","description":"Server-side rendering for react-router and react-meteor-data rehydratating Meteor subscriptions","fork":true,"url":"https://api.github.com/repos/yched/meteor-react-router-ssr","forks_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/forks","keys_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/teams","hooks_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/hooks","issue_events_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/issues/events{/number}","events_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/events","assignees_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/assignees{/user}","branches_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/branches{/branch}","tags_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/tags","blobs_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/git/refs{/sha}","trees_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/statuses/{sha}","languages_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/languages","stargazers_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/stargazers","contributors_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/contributors","subscribers_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/subscribers","subscription_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/subscription","commits_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/commits{/sha}","git_commits_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/git/commits{/sha}","comments_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/comments{/number}","issue_comment_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/issues/comments{/number}","contents_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/contents/{+path}","compare_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/merges","archive_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/downloads","issues_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/issues{/number}","pulls_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/pulls{/number}","milestones_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/milestones{/number}","notifications_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/labels{/name}","releases_url":"https://api.github.com/repos/yched/meteor-react-router-ssr/releases{/id}","created_at":"2015-12-22T16:34:28Z","updated_at":"2015-12-22T16:34:29Z","pushed_at":"2015-12-26T13:43:12Z","git_url":"git://github.com/yched/meteor-react-router-ssr.git","ssh_url":"git@github.com:yched/meteor-react-router-ssr.git","clone_url":"https://github.com/yched/meteor-react-router-ssr.git","svn_url":"https://github.com/yched/meteor-react-router-ssr","homepage":"","size":62,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"thereactivestack:master","ref":"master","sha":"fb2436d6627054daaf52ec93084b25a5b5110c4a","user":{"login":"thereactivestack","id":13560797,"avatar_url":"https://avatars.githubusercontent.com/u/13560797?v=3","gravatar_id":"","url":"https://api.github.com/users/thereactivestack","html_url":"https://github.com/thereactivestack","followers_url":"https://api.github.com/users/thereactivestack/followers","following_url":"https://api.github.com/users/thereactivestack/following{/other_user}","gists_url":"https://api.github.com/users/thereactivestack/gists{/gist_id}","starred_url":"https://api.github.com/users/thereactivestack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thereactivestack/subscriptions","organizations_url":"https://api.github.com/users/thereactivestack/orgs","repos_url":"https://api.github.com/users/thereactivestack/repos","events_url":"https://api.github.com/users/thereactivestack/events{/privacy}","received_events_url":"https://api.github.com/users/thereactivestack/received_events","type":"Organization","site_admin":false},"repo":{"id":40006835,"name":"meteor-react-router-ssr","full_name":"thereactivestack/meteor-react-router-ssr","owner":{"login":"thereactivestack","id":13560797,"avatar_url":"https://avatars.githubusercontent.com/u/13560797?v=3","gravatar_id":"","url":"https://api.github.com/users/thereactivestack","html_url":"https://github.com/thereactivestack","followers_url":"https://api.github.com/users/thereactivestack/followers","following_url":"https://api.github.com/users/thereactivestack/following{/other_user}","gists_url":"https://api.github.com/users/thereactivestack/gists{/gist_id}","starred_url":"https://api.github.com/users/thereactivestack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thereactivestack/subscriptions","organizations_url":"https://api.github.com/users/thereactivestack/orgs","repos_url":"https://api.github.com/users/thereactivestack/repos","events_url":"https://api.github.com/users/thereactivestack/events{/privacy}","received_events_url":"https://api.github.com/users/thereactivestack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thereactivestack/meteor-react-router-ssr","description":"Server-side rendering for react-router and react-meteor-data rehydratating Meteor subscriptions","fork":false,"url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr","forks_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/forks","keys_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/teams","hooks_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/hooks","issue_events_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/issues/events{/number}","events_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/events","assignees_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/assignees{/user}","branches_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/branches{/branch}","tags_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/tags","blobs_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/git/refs{/sha}","trees_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/statuses/{sha}","languages_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/languages","stargazers_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/stargazers","contributors_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/contributors","subscribers_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/subscribers","subscription_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/subscription","commits_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/commits{/sha}","git_commits_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/git/commits{/sha}","comments_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/comments{/number}","issue_comment_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/issues/comments{/number}","contents_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/contents/{+path}","compare_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/merges","archive_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/downloads","issues_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/issues{/number}","pulls_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls{/number}","milestones_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/milestones{/number}","notifications_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/labels{/name}","releases_url":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/releases{/id}","created_at":"2015-07-31T13:34:23Z","updated_at":"2015-12-24T04:25:57Z","pushed_at":"2015-12-26T13:43:13Z","git_url":"git://github.com/thereactivestack/meteor-react-router-ssr.git","ssh_url":"git@github.com:thereactivestack/meteor-react-router-ssr.git","clone_url":"https://github.com/thereactivestack/meteor-react-router-ssr.git","svn_url":"https://github.com/thereactivestack/meteor-react-router-ssr","homepage":"","size":59,"stargazers_count":39,"watchers_count":39,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":2,"forks":9,"open_issues":2,"watchers":39,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/24"},"html":{"href":"https://github.com/thereactivestack/meteor-react-router-ssr/pull/24"},"issue":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/issues/24"},"comments":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/thereactivestack/meteor-react-router-ssr/statuses/769d75d7d4d73044982f92474cd4748c07360dbc"}}}}