@blotoutio/providers-evo-search-sdk 1.52.0 → 1.53.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 +64 -0
- package/core.cjs.js +674 -0
- package/core.js +677 -0
- package/core.mjs +672 -0
- package/hooks.cjs.js +642 -0
- package/hooks.d.ts +98 -0
- package/hooks.mjs +638 -0
- package/index.cjs.js +239 -246
- package/index.js +239 -246
- package/index.mjs +239 -246
- package/package.json +28 -3
package/README.md
CHANGED
|
@@ -5,3 +5,67 @@ This library was generated with [Nx](https://nx.dev).
|
|
|
5
5
|
## Building
|
|
6
6
|
|
|
7
7
|
Run `nx build providers-evo-search-sdk` to build the library.
|
|
8
|
+
|
|
9
|
+
## Headless React integration
|
|
10
|
+
|
|
11
|
+
For headless storefronts (Hydrogen, Next.js, Remix, custom React apps) where the EdgeTag pixel is already installed and the EvoSearch provider is enabled on the tag, this package exports a React hook from the `/hooks` subpath.
|
|
12
|
+
|
|
13
|
+
Install:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @blotoutio/providers-evo-search-sdk
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Wrap your app once:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { EvoSearchProvider } from '@blotoutio/providers-evo-search-sdk/hooks'
|
|
23
|
+
|
|
24
|
+
export default function Root({ children }) {
|
|
25
|
+
return <EvoSearchProvider>{children}</EvoSearchProvider>
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use the hook in any search component:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { useEvoSearch } from '@blotoutio/providers-evo-search-sdk/hooks'
|
|
33
|
+
|
|
34
|
+
function HeaderSearch() {
|
|
35
|
+
const { query, setQuery, results, suggestions, loading, trackClick } = useEvoSearch()
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<input value={query} onChange={(e) => setQuery(e.target.value)} />
|
|
39
|
+
{loading && <span>Loading…</span>}
|
|
40
|
+
<ul>
|
|
41
|
+
{suggestions.map((s) => (
|
|
42
|
+
<li key={s.phrase}>{s.phrase}</li>
|
|
43
|
+
))}
|
|
44
|
+
</ul>
|
|
45
|
+
<ul>
|
|
46
|
+
{results.map((p) => (
|
|
47
|
+
<li key={p.id} onClick={() => trackClick(p.id)}>
|
|
48
|
+
{p.title}
|
|
49
|
+
</li>
|
|
50
|
+
))}
|
|
51
|
+
</ul>
|
|
52
|
+
</>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
For full API reference, see the design spec in the Blotout solutions repo or the docs site.
|
|
58
|
+
|
|
59
|
+
## Disabling the default UI (headless mode)
|
|
60
|
+
|
|
61
|
+
When you want to render search results with your own React components instead of the default Lit custom element, flip **Disable default UI** in the EvoSearch provider settings (edgetag admin → providers → EvoSearch). With this toggle on:
|
|
62
|
+
|
|
63
|
+
- The CDN serves a lighter `core.min.js` bundle instead of `index.min.js` — no Lit element, no default DOM.
|
|
64
|
+
- The React hook from the `/hooks` subpath continues to work — it reads the EvoSearch API from the same registry the default UI would have used.
|
|
65
|
+
- Changes take up to 25 minutes to propagate via the edge cache (`max-age=1500` on the `/load` response).
|
|
66
|
+
|
|
67
|
+
The EdgeTag pixel must still be loaded on your storefront for the SDK to register and the React hook to receive an API.
|
|
68
|
+
|
|
69
|
+
## /load endpoint cache
|
|
70
|
+
|
|
71
|
+
CDN responses for `/load` cache for ~25 minutes (`max-age=1500`). Toggling `Disable default UI` in the admin form takes up to that long to propagate across edge nodes — bake the delay into release planning.
|