@nosto/nosto-react 0.3.0 → 0.4.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
@@ -4,8 +4,6 @@ Nosto React is a React component library to make it even easier to implement Nos
4
4
 
5
5
  The library provides you everything to get started with personalisation on your React site. It's dead simple, and beginner friendly.
6
6
 
7
-
8
-
9
7
  ### Why?
10
8
 
11
9
  You should be using Nosto React if you want to:
@@ -14,23 +12,36 @@ You should be using Nosto React if you want to:
14
12
  - Customize your components at will and with ease
15
13
  - Follow React principles
16
14
 
15
+ ## Feature list
16
+
17
+ Our React component library includes the following features:
18
+
19
+ - Recommendations, including client-side rendering
20
+ - Onsite content personalisation
21
+ - Dynamic bundles
22
+ - Debug toolbar\* (excluding advanced use cases)
23
+ - Pop-ups & personalised emails
24
+ - A/B testing
25
+ - Segmentation and Insights
26
+ - Analytics
27
+ - Search\*\* (when implemented via our code editor)
28
+
29
+ _\*Note: Our React component library currently does not support advanced use cases of the debug toolbar, but we are constantly working to improve our library and provide you with the best possible integration options. We support most use-cases with page tagging and debug workflows._
17
30
 
31
+ _\*\*Note: The search feature is available when implemented via our code editor._
18
32
 
19
- ### Features
33
+ ### Additional features
20
34
 
21
35
  - ✓ Lightweight. Almost zero bloat.
22
36
  - ✓ Full support for the Facebook Pixel and Google Analytics.
23
37
  - ✓ Full support for leveraging overlays.
24
38
  - ✓ Full support for the JS API.
25
- - ✓ Full support for placements*.
26
- - ✓ Partial support for Nosto's Debug Toolbar. Supports most use-cases with page tagging and debug workflows.
27
- - ✘ No support for client-side rendering (SSR) for recommendations and content, yet.
28
-
29
- _*Note: dynamic placements are not supported on Shopify Hydrogen due to the React framework explicitly restricting injecting DOM elements in this way. This can be disabled explicitly via configuration. Static placements continue to be supported fully. Please see `<NostoPlacement>` below for more details._
39
+ - ✓ Full support for placements.
30
40
 
31
41
  ### Building
32
42
 
33
43
  #### Required versions
44
+
34
45
  - npm: 8.5.5
35
46
  - node: v16.15.0
36
47
 
@@ -44,8 +55,6 @@ _*Note: dynamic placements are not supported on Shopify Hydrogen due to the Reac
44
55
 
45
56
  npm install @nosto/nosto-react
46
57
 
47
-
48
-
49
58
  ### Getting Started
50
59
 
51
60
  ##### The root widget
@@ -57,26 +66,31 @@ This widget is what we call the Nosto root widget, which is responsible for addi
57
66
  ```jsx
58
67
  import { NostoProvider } from "@nosto/nosto-react";
59
68
 
60
- <NostoProvider account="your-nosto-account-id">
69
+ <NostoProvider
70
+ account="your-nosto-account-id"
71
+ recommendationComponent={<NostoSlot />}
72
+ >
61
73
  <App />
62
- </NostoProvider>
74
+ </NostoProvider>;
63
75
  ```
64
76
 
65
- **Note:** the component also accepts a prop to configure the host `host="connect.nosto.com"`. In advanced use-cases, the need to configure the host may surface.
77
+ **Note:** the component also accepts a prop to configure the host `host="connect.nosto.com"`. In advanced use-cases, the need to configure the host may surface.
78
+
79
+ #### Client side rendering for recommendations
66
80
 
81
+ In order to implement client-side rendering, the <NostoProvider> requires a designated component to render the recommendations provided by Nosto. This component should be capable of processing the JSON response received from our backend. Notice the `recommendationComponent={<NostoSlot />}` prop passed to `<NostoProvider>` above.
67
82
 
83
+ Learn more [here](https://github.com/Nosto/shopify-hydrogen/blob/main/README.md#client-side-rendering-for-recommendations) and see a [live example](https://github.com/Nosto/shopify-hydrogen-demo) on our demo store.
68
84
 
69
85
  ##### Understanding Placements
70
86
 
71
- Nosto React has a special component called `NostoPlacement`. The component is a simply a <u>hidden</u> `<div>` placeholder into which Nosto injects recommendations or personalises the content between the tags.
87
+ Nosto React has a special component called `NostoPlacement`. The component is a simply a <u>hidden</u> `<div>` placeholder into which Nosto injects recommendations or personalises the content between the tags.
72
88
 
73
89
  We recommend adding as many placements across your views as needed as these are hidden and only populated when a corresponding campaign (targeting that placement) is configured.
74
90
 
75
-
76
-
77
91
  ##### Managing the session
78
-
79
- Nosto React requires that you pass it the details of current cart contents and the details of the currently logged-in customer, if any, on every route change. This makes it easier to add attribution.
92
+
93
+ Nosto React requires that you pass it the details of current cart contents and the details of the currently logged-in customer, if any, on every route change. This makes it easier to add attribution.
80
94
 
81
95
  The `NostoSession` component makes it very easy to keep the session up to date so long as the cart and the customer are provided.
82
96
 
@@ -86,26 +100,20 @@ The `cart` prop requires a value that adheres to the type `Cart`, while the `cus
86
100
  import { NostoSession } from "@nosto/nosto-react";
87
101
 
88
102
  <>
89
- <Meta/>
90
- <header>
91
- <MainMenu/>
92
- <NostoSession cart={currentCart} customer={currentUser}/>
93
- </header>
94
- <Routes/>
95
- <Footer/>
96
- </>
103
+ <Meta />
104
+ <header>
105
+ <MainMenu />
106
+ <NostoSession cart={currentCart} customer={currentUser} />
107
+ </header>
108
+ <Routes />
109
+ <Footer />
110
+ </>;
97
111
  ```
98
112
 
99
-
100
-
101
-
102
-
103
113
  ### Adding Personalisation
104
114
 
105
115
  Nosto React ships with canned components for the different page types. Each component contains all lifecycle methods to dispatch the necessary events.
106
116
 
107
-
108
-
109
117
  ##### Personalising your home page
110
118
 
111
119
  The `NostoHome` component must be used to personalise the home page. The component does not require any props.
@@ -118,22 +126,18 @@ The `<NostoHome \>` component needs to be added after the placements. Content an
118
126
  import { NostoHome, NostoPlacement } from "@nosto/nosto-react";
119
127
 
120
128
  <div className="front-page">
121
- ...
122
- ...
123
- ...
129
+ ... ... ...
124
130
  <NostoPlacement id="frontpage-nosto-1" />
125
131
  <NostoPlacement id="frontpage-nosto-2" />
126
132
  <NostoPlacement id="frontpage-nosto-3" />
127
133
  <NostoPlacement id="frontpage-nosto-4" />
128
134
  <NostoHome />
129
- </div>
135
+ </div>;
130
136
  ```
131
137
 
132
-
133
-
134
138
  ##### Personalising your product pages
135
139
 
136
- The `NostoProduct` component must be used to personalise the product page. The component requires that you provide it the identifier of the current product being viewed.
140
+ The `NostoProduct` component must be used to personalise the product page. The component requires that you provide it the identifier of the current product being viewed.
137
141
 
138
142
  By default, your account, when created, has <u>three</u> product-page placements named `productpage-nosto-1`, `productpage-nosto-2` and `productpage-nosto-3`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
139
143
 
@@ -143,18 +147,14 @@ The `<NostoProduct \>` component needs to be added after the placements. Content
143
147
  import { NostoPlacement, NostoProduct } from "@nosto/nosto-react";
144
148
 
145
149
  <div className="product-page">
146
- ...
147
- ...
148
- ...
150
+ ... ... ...
149
151
  <NostoPlacement id="productpage-nosto-1" />
150
152
  <NostoPlacement id="productpage-nosto-2" />
151
153
  <NostoPlacement id="productpage-nosto-3" />
152
154
  <NostoProduct product={product.id} />
153
- </div>
155
+ </div>;
154
156
  ```
155
157
 
156
-
157
-
158
158
  ##### Personalising your search result pages
159
159
 
160
160
  You can personalise your search pages by using the `NostoSearch` component. The component requires that you provide it the current search term.
@@ -165,19 +165,15 @@ By default, your account, when created, has <u>two</u> search-page placements na
165
165
  import { NostoPlacement, NostoSearch } from "@nosto/nosto-react";
166
166
 
167
167
  <div className="search-page">
168
- ...
169
- ...
170
- ...
168
+ ... ... ...
171
169
  <NostoPlacement id="searchpage-nosto-1" />
172
170
  <NostoPlacement id="searchpage-nosto-2" />
173
171
  <NostoSearch query={search} />
174
- </div>
172
+ </div>;
175
173
  ```
176
174
 
177
175
  **Note:** Do not encode the search term in any way. It should be provided an unencoded string. A query for "black shoes" must be provided as-is and not as "black+shoes". Doing so will lead to invalid results.
178
176
 
179
-
180
-
181
177
  ##### Personalising your category list pages
182
178
 
183
179
  You can personalise your category and collection pages by using the `NostoCategory` component. The component requires that you provide it the the slash-delimited slug representation of the current category.
@@ -188,19 +184,15 @@ By default, your account, when created, has <u>two</u> category placements named
188
184
  import { NostoCategory, NostoPlacement } from "@nosto/nosto-react";
189
185
 
190
186
  <div className="category-page">
191
- ...
192
- ...
193
- ...
187
+ ... ... ...
194
188
  <NostoPlacement id="categorypage-nosto-1" />
195
189
  <NostoPlacement id="categorypage-nosto-2" />
196
190
  <NostoCategory category={category.name} />
197
- </div>
191
+ </div>;
198
192
  ```
199
193
 
200
194
  **Note:** Be sure to pass in the correct category representation. If the category being viewed is Mens >> Jackets, you must provide the name as `/Mens/Jackets` . You must ensure that the category path provided here matches that of the categories tagged in your products.
201
195
 
202
-
203
-
204
196
  ##### Personalising your cart checkout pages
205
197
 
206
198
  You can personalise your cart and checkout pages by using the `NostoCheckout` component. The component does not require any props.
@@ -211,20 +203,16 @@ By default, your account, when created, has <u>two</u> cart-page placements name
211
203
  import { NostoCheckout, NostoPlacement } from "@nosto/nosto-react";
212
204
 
213
205
  <div className="checkout-page">
214
- ...
215
- ...
216
- ...
206
+ ... ... ...
217
207
  <NostoPlacement id="checkout-nosto-1" />
218
208
  <NostoPlacement id="checkout-nosto-2" />
219
209
  <NostoCheckout />
220
- </div>
210
+ </div>;
221
211
  ```
222
212
 
223
-
224
-
225
213
  ##### Personalising your 404 error pages
226
214
 
227
- You can personalise your cart and checkout pages by using the `Nosto404` component. The component does not require any props.
215
+ You can personalise not found pages by using the `Nosto404` component. The component does not require any props.
228
216
 
229
217
  By default, your account, when created, has three 404-page placements named `notfound-nosto-1`, `notfound-nosto-2` and `notfound-nosto-2`. You may omit these and use any identifier you need. The identifiers used here are simply provided to illustrate the example.
230
218
 
@@ -232,18 +220,14 @@ By default, your account, when created, has three 404-page placements named `not
232
220
  import { Nosto404, NostoPlacement } from "@nosto/nosto-react";
233
221
 
234
222
  <div className="notfound-page">
235
- ...
236
- ...
237
- ...
223
+ ... ... ...
238
224
  <NostoPlacement id="notfound-nosto-1" />
239
225
  <NostoPlacement id="notfound-nosto-2" />
240
226
  <NostoPlacement id="notfound-nosto-3" />
241
227
  <Nosto404 />
242
- </div>
228
+ </div>;
243
229
  ```
244
230
 
245
-
246
-
247
231
  ##### Personalising your miscellaneous pages
248
232
 
249
233
  You can personalise your miscellaneous pages by using the `NostoOther` component. The component does not require any props.
@@ -254,17 +238,13 @@ By default, your account, when created, has two other-page placements named `oth
254
238
  import { NostoOther, NostoPlacement } from "@nosto/nosto-react";
255
239
 
256
240
  <div className="other-page">
257
- ...
258
- ...
259
- ...
241
+ ... ... ...
260
242
  <NostoPlacement id="other-nosto-1" />
261
243
  <NostoPlacement id="other-nosto-2" />
262
244
  <NostoOther />
263
- </div>
245
+ </div>;
264
246
  ```
265
247
 
266
-
267
-
268
248
  ##### Personalising your order confirmation page
269
249
 
270
250
  You can personalise your order-confirmation/thank-you page by using the `NostoOrder` component. The component requires that you provide it with the details of the order.
@@ -274,31 +254,31 @@ By default, your account, when created, has one other-page placement named `than
274
254
  The `order` prop requires a value that adheres to the type `Purchase`.
275
255
 
276
256
  ```jsx
277
- import { Buyer, Item, NostoOrder, NostoPlacement, Purchase } from "@nosto/nosto-react";
257
+ import {
258
+ Buyer,
259
+ Item,
260
+ NostoOrder,
261
+ NostoPlacement,
262
+ Purchase,
263
+ } from "@nosto/nosto-react";
278
264
 
279
265
  <div className="thankyou-page">
280
- ...
281
- ...
282
- ...
266
+ ... ... ...
283
267
  <NostoPlacement id="thankyou-nosto-1" />
284
268
  <NostoOrder order={{ purchase: toOrder(order) }} />
285
- </div>
269
+ </div>;
286
270
  ```
287
271
 
288
272
  ### Feedback
289
273
 
290
- If you've found a feature missing or you would like to report an issue, simply [open up an issue](https://github.com/nosto/nosto-react/issues/new) and let us know.
274
+ If you've found a feature missing or you would like to report an issue, simply [open up an issue](https://github.com/nosto/nosto-react/issues/new) and let us know.
291
275
 
292
276
  We're always collecting feedback and learning from your use-cases. If you find your self customising widgets and forking the repo to make patches - do drop a message. We'd love to know more and understand how we can make React Nosto an even slicker library for you.
293
277
 
294
-
295
-
296
278
  ### Contributing
297
279
 
298
280
  Please take a moment to review the guidelines for contributing.
299
281
 
300
-
301
-
302
282
  ### License
303
283
 
304
284
  MIT