📱React User Agent Component and Provider, SSR-ready, using new React Context API
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.babelrc
.eslintrc
.gitignore
.prettierrc
.travis.yml
LICENSE
README.md
package.json
yarn.lock

README.md

react-ua

npm version Build Status

React User Agent Component and Provider, SSR-ready, using new React Context API

Features

Try it live at StackBlitz

import React from 'react';
import { UserAgentProvider, UserAgent } from 'react-ua';

const App = () => (
  <UserAgent>{ua => <div>OS: {ua.os.name}</div>}</UserAgent>
)

const Home = () => (
  <UserAgentProvider>
    <App />
  </UserAgentProvider>
);

ReactDOM.render(<Home />, document.getElementById("#root"))

// SSR
const el = (
  <UserAgentProvider value={request.headers['user-agent']}>
    <App />
  </UserAgentProvider>
);

ReactDOMServer.renderToString(el);

License

MIT