An open API service indexing awesome lists of open source software.

https://github.com/antonybudianto/react-client-hints

React User Agent Client Hints Hooks, Component, and Provider. SSR-ready and fully unit-tested.
https://github.com/antonybudianto/react-client-hints

client-hints react react-hooks user-agent

Last synced: about 1 year ago
JSON representation

React User Agent Client Hints Hooks, Component, and Provider. SSR-ready and fully unit-tested.

Awesome Lists containing this project

README

          

# react-client-hints

[![npm version](https://badge.fury.io/js/react-client-hints.svg)](https://badge.fury.io/js/react-client-hints)
[![Build Status](https://travis-ci.org/antonybudianto/react-client-hints.svg?branch=master)](https://travis-ci.org/antonybudianto/react-client-hints)



React Client Hints Hooks, Component, and Provider. SSR-ready and fully unit-tested.

## Requirement

- React 16.8.0

## Features

- Provide simple API for latest [Client Hints feature](https://developer.mozilla.org/en-US/docs/Glossary/Client_hints)
- Using new React [Context API](https://reactjs.org/docs/context.html)
- SSR-ready
- Fully unit-tested

> Try it [live at StackBlitz](https://stackblitz.com/edit/demo-react-client-hints)

```js
import React, { Component } from 'react';
import { render } from 'react-dom';
import { ClientHintsProvider, useClientHints } from 'react-client-hints';

const Hello = () => {
const ch = useClientHints();
return

Platform: {ch && ch.platform}
;
};

const App = () => {
return (



);
};

render(, document.getElementById('root'));

// SSR with compatible header object
const el = (

{ch => ch.platform}

);

ReactDOMServer.renderToString(el);
```

## License

MIT