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.
- Host: GitHub
- URL: https://github.com/antonybudianto/react-client-hints
- Owner: antonybudianto
- License: mit
- Created: 2020-05-15T17:32:44.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T06:00:42.000Z (over 3 years ago)
- Last Synced: 2025-03-18T01:51:22.193Z (about 1 year ago)
- Topics: client-hints, react, react-hooks, user-agent
- Language: JavaScript
- Homepage: https://stackblitz.com/edit/demo-react-client-hints
- Size: 2.34 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-client-hints
[](https://badge.fury.io/js/react-client-hints)
[](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