${ReactDOMServer.renderToString(
)}
`);
});
app.listen(3000, () => {
console.log('Running on http://localhost:3000/');
});
```
### Preloading all your loadable components on the server
The first step to rendering the correct content from the server is to make sure
that all of your loadable components are already loaded when you go to render
them.
To do this, you can use the [`Loadable.preloadAll`](#loadablepreloadall)
method. It returns a promise that will resolve when all your loadable
components are ready.
```js
Loadable.preloadAll().then(() => {
app.listen(3000, () => {
console.log('Running on http://localhost:3000/');
});
});
```
### Picking up a server-side rendered app on the client
This is where things get a little bit tricky. So let's prepare ourselves
little bit.
In order for us to pick up what was rendered from the server we need to have
all the same code that was used to render on the server.
To do this, we first need our loadable components telling us which modules they
are rendering.
#### Declaring which modules are being loaded
There are two options in [`Loadable`](#loadable) and
[`Loadable.Map`](#loadablemap) which are used to tell us which modules our
component is trying to load: [`opts.modules`](#optsmodules) and
[`opts.webpack`](#optswebpack).
```js
Loadable({
loader: () => import('./Bar'),
modules: ['./Bar'],
webpack: () => [require.resolveWeak('./Bar')],
});
```
But don't worry too much about these options. React Loadable includes a
[Babel plugin](#babel-plugin) to add them for you.
Just add the `react-loadable/babel` plugin to your Babel config:
```json
{
"plugins": [
"react-loadable/babel"
]
}
```
Now these options will automatically be provided.
#### Finding out which dynamic modules were rendered
Next we need to find out which modules were actually rendered when a request
comes in.
For this, there is [`Loadable.Capture`](#loadablecapture) component which can
be used to collect all the modules that were rendered.
```js
import Loadable from 'react-loadable';
app.get('/', (req, res) => {
let modules = [];
let html = ReactDOMServer.renderToString(