@cohostvip/cohost-react 0.0.2

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.
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @cohostvip/cohost-react
2
+
3
+ React bindings for the [Cohost API](https://cohost.vip), built on top of [`@cohostvip/cohost-node`](https://www.npmjs.com/package/@cohostvip/cohost-node).
4
+
5
+ Use this package to easily connect your React or Next.js app to Cohost's event and order APIs using a provider/hook pattern.
6
+
7
+ ---
8
+
9
+ ## 📦 Installation
10
+
11
+ ```bash
12
+ pnpm add @cohostvip/cohost-react
13
+ ```
14
+
15
+ Or with npm:
16
+
17
+ ```bash
18
+ npm install @cohostvip/cohost-react
19
+ ```
20
+
21
+ ---
22
+
23
+ ## 🚀 Usage
24
+
25
+ Wrap your app (or part of it) in the `CohostProvider` and use the `useCohost()` hook to access the API client.
26
+
27
+ ### Example
28
+
29
+ ```tsx
30
+ // app.tsx or layout.tsx
31
+ import { CohostProvider } from '@cohostvip/cohost-react';
32
+
33
+ export function App() {
34
+ return (
35
+ <CohostProvider token="your-api-token">
36
+ <MyComponent />
37
+ </CohostProvider>
38
+ );
39
+ }
40
+ ```
41
+
42
+ ```tsx
43
+ // inside your component
44
+ import { useCohost } from '@cohostvip/cohost-react';
45
+
46
+ function MyComponent() {
47
+ const cohost = useCohost();
48
+
49
+ useEffect(() => {
50
+ cohost.events.list().then(console.log);
51
+ }, []);
52
+
53
+ return <div>Loaded events</div>;
54
+ }
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 🔐 Auth
60
+
61
+ Pass your API `token` to the `CohostProvider`. This token is required for all authenticated requests.
62
+ You can optionally pass:
63
+
64
+ - `baseUrl` — override the default API URL (e.g. for staging)
65
+ - `debug` — enable console debugging of API requests
66
+
67
+ ---
68
+
69
+ ## 📘 API Reference
70
+
71
+ This wrapper gives you access to the full Cohost API as defined in [`@cohostvip/cohost-node`](https://www.npmjs.com/package/@cohostvip/cohost-node).
72
+ See its documentation for available methods like:
73
+
74
+ - `client.events.list()`
75
+ - `client.orders.fetch(orderId, userId)`
76
+ - etc.
77
+
78
+ ---
79
+
80
+ ## ✅ Requirements
81
+
82
+ - React 18 or 19
83
+ - Next.js 14 or 15
84
+
85
+ ---
86
+
87
+ ## 🛠️ Support
88
+
89
+ If you're building something custom or need help integrating, reach out at [cohost.vip](https://cohost.vip) or open an issue.
90
+
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { type CohostClient } from '@cohostvip/cohost-node';
3
+ export interface CohostProviderProps {
4
+ token: string;
5
+ children: React.ReactNode;
6
+ }
7
+ export declare const CohostProvider: React.FC<CohostProviderProps>;
8
+ export declare const useCohostClient: () => CohostClient;
9
+ //# sourceMappingURL=CohostContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CohostContext.d.ts","sourceRoot":"","sources":["../../src/context/CohostContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE/E,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAID,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAWxD,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,YAIlC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ import { createCohostClient } from '@cohostvip/cohost-node';
4
+ const CohostContext = createContext(null);
5
+ export const CohostProvider = ({ token, children, }) => {
6
+ const client = createCohostClient({ token }); // assumes a factory fn in cohost-node
7
+ return (_jsx(CohostContext.Provider, { value: client, children: children }));
8
+ };
9
+ export const useCohostClient = () => {
10
+ const ctx = useContext(CohostContext);
11
+ if (!ctx)
12
+ throw new Error("useCohostClient must be used within a CohostProvider");
13
+ return ctx;
14
+ };
@@ -0,0 +1,2 @@
1
+ export { useCohostClient as useCohost } from '../context/CohostContext';
2
+ //# sourceMappingURL=useCohost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCohost.d.ts","sourceRoot":"","sources":["../../src/hooks/useCohost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,IAAI,SAAS,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ export { useCohostClient as useCohost } from '../context/CohostContext';
@@ -0,0 +1,3 @@
1
+ export { CohostProvider } from './context/CohostContext';
2
+ export { useCohost } from './hooks/useCohost';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { CohostProvider } from './context/CohostContext';
2
+ export { useCohost } from './hooks/useCohost';
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@cohostvip/cohost-react",
3
+ "version": "0.0.2",
4
+ "description": "React bindings for the Cohost API",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc --project tsconfig.json",
19
+ "dev": "tsc --watch --project tsconfig.json",
20
+ "clean": "rm -rf dist",
21
+ "test": "vitest",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "peerDependencies": {
25
+ "react": "^18.0.0 || ^19.0.0",
26
+ "react-dom": "^18.0.0 || ^19.0.0"
27
+ },
28
+ "dependencies": {
29
+ "@cohostvip/cohost-node": "0.0.2"
30
+ },
31
+ "devDependencies": {
32
+ "@testing-library/jest-dom": "6.6.3",
33
+ "@testing-library/react": "^16.3.0",
34
+ "@types/react": "19.0.10",
35
+ "@types/react-dom": "19.0.4",
36
+ "jsdom": "26.0.0",
37
+ "typescript": "^5.8.3",
38
+ "vitest": "^3.1.1"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "https://github.com/cohostvip/cohost-react.git"
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/cohostvip/cohost-react/issues"
46
+ },
47
+ "homepage": "https://github.com/cohostvip/cohost-react",
48
+ "author": "Cohost <support@cohost.vip> (https://cohost.vip)",
49
+ "license": "MIT",
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "engines": {
54
+ "node": ">=18.0.0"
55
+ },
56
+ "keywords": [
57
+ "cohost",
58
+ "react",
59
+ "nextjs",
60
+ "api",
61
+ "context",
62
+ "provider",
63
+ "sdk",
64
+ "typescript"
65
+ ]
66
+ }