@algolia/wizard 0.34.0-rc.125.245 → 0.34.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.
|
@@ -4,18 +4,13 @@ Install `instantsearch.js` (v4)
|
|
|
4
4
|
|
|
5
5
|
## Search client: always use the lite client
|
|
6
6
|
|
|
7
|
-
Import the client from `algoliasearch/lite` and alias it to `algoliasearch
|
|
8
|
-
`ALGOLIA_APP_ID`, `ALGOLIA_SEARCH_API_KEY`, and `ALGOLIA_INDEX_NAME` below are
|
|
9
|
-
the constants exported from the project's shared client-side config module —
|
|
10
|
-
these are public values, safe to commit; never hardcode them inline or read
|
|
11
|
-
them from an env var.
|
|
7
|
+
Import the client from `algoliasearch/lite` and alias it to `algoliasearch`
|
|
12
8
|
|
|
13
9
|
```ts
|
|
14
10
|
import { liteClient as algoliasearch } from 'algoliasearch/lite'
|
|
15
|
-
import { ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY } from '<the project's shared config module>'
|
|
16
11
|
|
|
17
12
|
// Instantiate ONCE, outside components, with a stable reference.
|
|
18
|
-
const searchClient = algoliasearch(
|
|
13
|
+
const searchClient = algoliasearch(APP_ID, SEARCH_ONLY_KEY)
|
|
19
14
|
```
|
|
20
15
|
|
|
21
16
|
## Vanilla (`instantsearch.js` v4)
|
|
@@ -24,16 +19,11 @@ const searchClient = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY)
|
|
|
24
19
|
import { liteClient as algoliasearch } from 'algoliasearch/lite'
|
|
25
20
|
import instantsearch from 'instantsearch.js'
|
|
26
21
|
import { searchBox, hits } from 'instantsearch.js/es/widgets'
|
|
27
|
-
import {
|
|
28
|
-
ALGOLIA_APP_ID,
|
|
29
|
-
ALGOLIA_SEARCH_API_KEY,
|
|
30
|
-
ALGOLIA_INDEX_NAME,
|
|
31
|
-
} from '<the project's shared config module>'
|
|
32
22
|
|
|
33
|
-
const searchClient = algoliasearch(
|
|
23
|
+
const searchClient = algoliasearch(APP_ID, SEARCH_ONLY_KEY)
|
|
34
24
|
|
|
35
25
|
const search = instantsearch({
|
|
36
|
-
indexName:
|
|
26
|
+
indexName: 'INDEX_NAME',
|
|
37
27
|
searchClient,
|
|
38
28
|
insights: true,
|
|
39
29
|
})
|
|
@@ -63,7 +53,7 @@ case, install `search-insights` from npm and pass its default export as
|
|
|
63
53
|
import aa from 'search-insights'
|
|
64
54
|
|
|
65
55
|
const search = instantsearch({
|
|
66
|
-
indexName:
|
|
56
|
+
indexName: 'INDEX_NAME',
|
|
67
57
|
searchClient,
|
|
68
58
|
insights: { insightsClient: aa },
|
|
69
59
|
})
|
|
@@ -4,18 +4,13 @@ Install `react-instantsearch` (v7)
|
|
|
4
4
|
|
|
5
5
|
## Search client: always use the lite client
|
|
6
6
|
|
|
7
|
-
Import the client from `algoliasearch/lite` and alias it to `algoliasearch
|
|
8
|
-
`ALGOLIA_APP_ID`, `ALGOLIA_SEARCH_API_KEY`, and `ALGOLIA_INDEX_NAME` below are
|
|
9
|
-
the constants exported from the project's shared client-side config module —
|
|
10
|
-
these are public values, safe to commit; never hardcode them inline or read
|
|
11
|
-
them from an env var.
|
|
7
|
+
Import the client from `algoliasearch/lite` and alias it to `algoliasearch`
|
|
12
8
|
|
|
13
9
|
```ts
|
|
14
10
|
import { liteClient as algoliasearch } from 'algoliasearch/lite'
|
|
15
|
-
import { ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY } from '<the project's shared config module>'
|
|
16
11
|
|
|
17
12
|
// Instantiate ONCE, outside components, with a stable reference.
|
|
18
|
-
const searchClient = algoliasearch(
|
|
13
|
+
const searchClient = algoliasearch(APP_ID, SEARCH_ONLY_KEY)
|
|
19
14
|
```
|
|
20
15
|
|
|
21
16
|
## React (`react-instantsearch` v7)
|
|
@@ -23,19 +18,19 @@ const searchClient = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY)
|
|
|
23
18
|
```tsx
|
|
24
19
|
import { liteClient as algoliasearch } from 'algoliasearch/lite'
|
|
25
20
|
import { InstantSearch, SearchBox, Hits } from 'react-instantsearch'
|
|
26
|
-
import {
|
|
27
|
-
ALGOLIA_APP_ID,
|
|
28
|
-
ALGOLIA_SEARCH_API_KEY,
|
|
29
|
-
ALGOLIA_INDEX_NAME,
|
|
30
|
-
} from '<the project's shared config module>'
|
|
31
21
|
|
|
32
|
-
|
|
22
|
+
// Read from PUBLIC env vars; never hardcode. (Vite shown; use the framework's
|
|
23
|
+
// convention: NEXT_PUBLIC_* for Next.js, etc.)
|
|
24
|
+
const searchClient = algoliasearch(
|
|
25
|
+
import.meta.env.VITE_ALGOLIA_APP_ID,
|
|
26
|
+
import.meta.env.VITE_ALGOLIA_SEARCH_API_KEY,
|
|
27
|
+
)
|
|
33
28
|
|
|
34
29
|
export function Search() {
|
|
35
30
|
return (
|
|
36
31
|
<InstantSearch
|
|
37
32
|
searchClient={searchClient}
|
|
38
|
-
indexName=
|
|
33
|
+
indexName="INDEX_NAME"
|
|
39
34
|
insights={true}
|
|
40
35
|
>
|
|
41
36
|
<SearchBox />
|
|
@@ -4,18 +4,13 @@ Install `vue-instantsearch` (v4)
|
|
|
4
4
|
|
|
5
5
|
## Search client: always use the lite client
|
|
6
6
|
|
|
7
|
-
Import the client from `algoliasearch/lite` and alias it to `algoliasearch
|
|
8
|
-
`ALGOLIA_APP_ID`, `ALGOLIA_SEARCH_API_KEY`, and `ALGOLIA_INDEX_NAME` below are
|
|
9
|
-
the constants exported from the project's shared client-side config module —
|
|
10
|
-
these are public values, safe to commit; never hardcode them inline or read
|
|
11
|
-
them from an env var.
|
|
7
|
+
Import the client from `algoliasearch/lite` and alias it to `algoliasearch`
|
|
12
8
|
|
|
13
9
|
```ts
|
|
14
10
|
import { liteClient as algoliasearch } from 'algoliasearch/lite'
|
|
15
|
-
import { ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY } from '<the project's shared config module>'
|
|
16
11
|
|
|
17
12
|
// Instantiate ONCE, outside components, with a stable reference.
|
|
18
|
-
const searchClient = algoliasearch(
|
|
13
|
+
const searchClient = algoliasearch(APP_ID, SEARCH_ONLY_KEY)
|
|
19
14
|
```
|
|
20
15
|
|
|
21
16
|
## Vue (`vue-instantsearch` v4)
|
|
@@ -24,7 +19,7 @@ const searchClient = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY)
|
|
|
24
19
|
<template>
|
|
25
20
|
<ais-instant-search
|
|
26
21
|
:search-client="searchClient"
|
|
27
|
-
|
|
22
|
+
index-name="INDEX_NAME"
|
|
28
23
|
:insights="true"
|
|
29
24
|
>
|
|
30
25
|
<ais-search-box />
|
|
@@ -34,13 +29,11 @@ const searchClient = algoliasearch(ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY)
|
|
|
34
29
|
|
|
35
30
|
<script setup>
|
|
36
31
|
import { liteClient as algoliasearch } from 'algoliasearch/lite'
|
|
37
|
-
import {
|
|
38
|
-
ALGOLIA_APP_ID,
|
|
39
|
-
ALGOLIA_SEARCH_API_KEY,
|
|
40
|
-
ALGOLIA_INDEX_NAME,
|
|
41
|
-
} from '<the project's shared config module>'
|
|
42
32
|
|
|
43
|
-
const searchClient = algoliasearch(
|
|
33
|
+
const searchClient = algoliasearch(
|
|
34
|
+
import.meta.env.VITE_ALGOLIA_APP_ID,
|
|
35
|
+
import.meta.env.VITE_ALGOLIA_SEARCH_API_KEY,
|
|
36
|
+
)
|
|
44
37
|
</script>
|
|
45
38
|
```
|
|
46
39
|
|
|
@@ -5,19 +5,10 @@ route, or programmatic queries). For UI, prefer `instantsearch-setup-<framework>
|
|
|
5
5
|
|
|
6
6
|
## Client
|
|
7
7
|
|
|
8
|
-
`ALGOLIA_APP_ID`, `ALGOLIA_SEARCH_API_KEY`, and `ALGOLIA_INDEX_NAME` below are
|
|
9
|
-
the constants exported from the project's shared client-side config module —
|
|
10
|
-
these are public values, safe to commit; never hardcode them inline or read
|
|
11
|
-
them from an env var.
|
|
12
|
-
|
|
13
8
|
```ts
|
|
14
9
|
import { algoliasearch } from 'algoliasearch'
|
|
15
|
-
import {
|
|
16
|
-
ALGOLIA_APP_ID,
|
|
17
|
-
ALGOLIA_SEARCH_API_KEY,
|
|
18
|
-
} from '<the project's shared config module>'
|
|
19
10
|
|
|
20
|
-
const client = algoliasearch(
|
|
11
|
+
const client = algoliasearch(APP_ID, SEARCH_ONLY_KEY)
|
|
21
12
|
```
|
|
22
13
|
|
|
23
14
|
In v5 there is no `client.initIndex(...)`. Index methods take the index name as a
|
|
@@ -27,7 +18,7 @@ parameter on the client. Every method takes a single options object.
|
|
|
27
18
|
|
|
28
19
|
```ts
|
|
29
20
|
const { hits, nbHits } = await client.searchSingleIndex({
|
|
30
|
-
indexName:
|
|
21
|
+
indexName: 'INDEX_NAME',
|
|
31
22
|
searchParams: { query: 'shoes', hitsPerPage: 20, page: 0 },
|
|
32
23
|
})
|
|
33
24
|
```
|
|
@@ -37,7 +28,7 @@ const { hits, nbHits } = await client.searchSingleIndex({
|
|
|
37
28
|
```ts
|
|
38
29
|
const { results } = await client.search({
|
|
39
30
|
requests: [
|
|
40
|
-
{ indexName:
|
|
31
|
+
{ indexName: 'INDEX_NAME', query: 'shoes' },
|
|
41
32
|
{ indexName: 'OTHER_INDEX', query: 'shoes' },
|
|
42
33
|
],
|
|
43
34
|
})
|