@youth-healthtech/web-sdk 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +22 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -43,6 +43,28 @@ nextCheckup(iframe, address, { user: { age: 35, height: 180, weight: 78 } });
43
43
  stop();
44
44
  ```
45
45
 
46
+ In React, start the checkup in an effect and return `stop` as its cleanup. Starting again on the
47
+ same iframe stops the earlier checkup first, so each event arrives once, under StrictMode too:
48
+
49
+ ```tsx
50
+ import { useEffect, useRef } from "react";
51
+ import { startCheckup } from "@youth-healthtech/web-sdk";
52
+
53
+ function Checkup({ apiKey }: { apiKey: string }) {
54
+ const iframe = useRef<HTMLIFrameElement>(null);
55
+ useEffect(() => {
56
+ if (!iframe.current) return;
57
+ return startCheckup(
58
+ iframe.current,
59
+ "https://sdk.youth-platform.io/embed.html",
60
+ { apiKey },
61
+ { onResult: (biomarkers) => save(biomarkers), onError: (code) => showError(code) },
62
+ );
63
+ }, [apiKey]);
64
+ return <iframe ref={iframe} title="Health checkup" style={{ width: "100%", height: 640 }} />;
65
+ }
66
+ ```
67
+
46
68
  Your organization's admins issue its keys in the YOU(th) console, under SDK, Keys. The key alone
47
69
  decides the environment: `pk_test_…` is a test (never billed, with its own limits) and `pk_live_…`
48
70
  is live (billed). You build and test with your test key, and go live by swapping it for your live
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youth-healthtech/web-sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Runs a YOU(th) checkup in an iframe on your page: loads it, starts it with your settings and reports its progress, its result and its errors.",
5
5
  "keywords": [
6
6
  "biomarkers",