> For the complete documentation index, see [llms.txt](https://react-use-api.gitbook.io/react-use-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://react-use-api.gitbook.io/react-use-api/server-side-rendering/ssr-settings.md).

# SSR Settings

react-use-api guarantees that the SSR for each HTTP request is thread-safe as long as passing the api context with SSR settings to `ApiProvider`.

### **SSR and injecting the cached api data**

{% code title="server/render.js" %}

```jsx
// server/render.js (based on Express framework)
import React from 'react'
import ReactDom from 'react-dom'
import { StaticRouter } from 'react-router-dom'
import { ApiProvider, injectSSRHtml } from 'react-use-api'

import App from '../../src/App'

export const render = async (req, axios) => {
  const { url } = req
  const apiContext = {
    settings: {
      axios, // your custom axios instance
      isSSR: () => true // we are 100% sure here is SSR mode
    }
  }
  const routerContext = {}
  const renderSSR = () =>
    ReactDom.renderToString(
      <ApiProvider context={apiContext}>
        <StaticRouter location={url} context={routerContext}>
          <App />
        </StaticRouter>
      </ApiProvider>
    )
  const html = await injectSSRHtml(apiContext, renderSSR)
  return html
}
```

{% endcode %}

#### **The cache data is inserted into the html text as well.**

> The cache data will be cleaned up after calling loadApiCache() by default

```markup
<script>
  window.__USE_API_CACHE__ = '[{ ... }]' // the cache data
</script>
```
