Usage with React Native
amaury1093 opened this issue · comments
Amaury commented
Support plan
- which support plan is this issue covered by? Community
- is this issue currently blocking your project? yes
- is this issue affecting a production system? no
Context
- node version: 13.6.0 (but using it in React Native)
- module version with issue: 4.0.0
- last module version without issue: unknown
- environment (e.g. node, browser, native): React Native
- used with (e.g. hapi application, another framework, standalone, ...): React Native
- any other relevant information:
What are you trying to achieve or the steps to reproduce?
Concretely, in my code, I'm doing this:
import Hawk from '@hapi/hawk';
And @hapi/hawk
depends on @hapi/sntp
.
What was the result you got?
What result did you expect?
Be able to use @hapi/sntp
Notes
I can think of 2 solutions:
- Add a dgram polyfill in my react native app, e.g. https://github.com/tradle/react-native-udp
- Change
@hapi/sntp
to not use nodejs-specific API. e.g.: would it be possible to replace dgram with ws/http requests?
Additional question
How does @hapi/sntp
work in browser (which don't support UDP)? If there's a plan to make @hapi/sntp
work in browser too, then the solution 2 above seems to be the optimal choice.
Eran Hammer commented
If you are trying to use the hawk client in the browser, import just that directly (lib/browser.js
), not the entire module as it is designed to work only server-side on node.