@nexly/react-web 0.4.0 → 0.6.0

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 CHANGED
@@ -49,6 +49,16 @@ function App() {
49
49
 
50
50
  Returns `Nexly | null` inside a provider (`null` if any credential trims to empty).
51
51
 
52
+ ### Using outside React (plain functions)
53
+
54
+ The provider initializes a global singleton. Access it anywhere without hooks:
55
+
56
+ ```ts
57
+ import { Nexly } from '@nexly/react-web'
58
+
59
+ Nexly.getInstance()?.event({ name: 'cta_click', type: 'conversion' })
60
+ ```
61
+
52
62
  ## Next.js
53
63
 
54
64
  For Next.js App Router (route-aware `autoPageView` on every navigation), use **[@nexly/next](https://www.npmjs.com/package/@nexly/next)** instead.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { NexlyProvider, useNexlyClient, type NexlyProviderProps } from './nexly-provider.js';
2
+ export { Nexly } from '@nexly/core';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC5F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { NexlyProvider, useNexlyClient } from './nexly-provider.js';
2
+ export { Nexly } from '@nexly/core';
@@ -1,7 +1,8 @@
1
1
  import { Nexly } from '@nexly/core';
2
2
  import { type ReactNode } from 'react';
3
3
  export type NexlyProviderProps = {
4
- collectUrl: string;
4
+ /** Override the ingest endpoint. Defaults to the Nexly production gateway. */
5
+ collectUrl?: string;
5
6
  appId: string;
6
7
  /** Ingest API token (maps to `key` on {@link Nexly}). Not named `key` — reserved in React. */
7
8
  ingestKey: string;
@@ -1 +1 @@
1
- {"version":3,"file":"nexly-provider.d.ts","sourceRoot":"","sources":["../src/nexly-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAA;IACjB,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+HAA+H;IAC/H,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,KAAK,EACL,SAAS,EACT,YAAoB,EACpB,cAAsB,EACtB,QAAQ,GACT,EAAE,kBAAkB,2CAyBpB;AAED,sIAAsI;AACtI,wBAAgB,cAAc,IAAI,KAAK,GAAG,IAAI,CAE7C"}
1
+ {"version":3,"file":"nexly-provider.d.ts","sourceRoot":"","sources":["../src/nexly-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAiD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAA;IACjB,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+HAA+H;IAC/H,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AAED,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,KAAK,EACL,SAAS,EACT,YAAoB,EACpB,cAAsB,EACtB,QAAQ,GACT,EAAE,kBAAkB,2CAwBpB;AAED,sIAAsI;AACtI,wBAAgB,cAAc,IAAI,KAAK,GAAG,IAAI,CAE7C"}
@@ -4,13 +4,12 @@ import { createContext, useContext, useEffect, useMemo } from 'react';
4
4
  const NexlyClientContext = createContext(null);
5
5
  export function NexlyProvider({ collectUrl, appId, ingestKey, autoPageView = false, autoEngagement = false, children, }) {
6
6
  const client = useMemo(() => {
7
- const u = collectUrl.trim();
8
7
  const id = appId.trim();
9
8
  const k = ingestKey.trim();
10
- if (!u || !id || !k) {
9
+ if (!id || !k) {
11
10
  return null;
12
11
  }
13
- return new Nexly({ collectUrl: u, appId: id, key: k });
12
+ return Nexly.init({ collectUrl, appId: id, key: k });
14
13
  }, [collectUrl, appId, ingestKey]);
15
14
  useEffect(() => {
16
15
  if (autoPageView && client) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexly/react-web",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "React bindings for Nexly (@nexly/core): provider, client hook, engagement, optional auto pageview",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -39,7 +39,7 @@
39
39
  "react": "^18.0.0 || ^19.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@nexly/core": "0.4.0"
42
+ "@nexly/core": "0.6.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/react": "^19.2.14",