@requiply/nuxt 0.0.0-stage → 0.1.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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +644 -2
- package/dist/module.d.mts +16 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +83 -0
- package/dist/runtime/app/components/RequiplyAccountLinks.d.ts +53 -0
- package/dist/runtime/app/components/RequiplyAccountLinks.js +13 -0
- package/dist/runtime/app/components/RequiplyBookButton.d.ts +37 -0
- package/dist/runtime/app/components/RequiplyBookButton.js +6 -0
- package/dist/runtime/app/components/RequiplyBundle.d.ts +21 -0
- package/dist/runtime/app/components/RequiplyBundle.js +4 -0
- package/dist/runtime/app/components/RequiplyCallButton.d.ts +35 -0
- package/dist/runtime/app/components/RequiplyCallButton.js +6 -0
- package/dist/runtime/app/components/RequiplyCartButton.d.ts +24 -0
- package/dist/runtime/app/components/RequiplyCartButton.js +4 -0
- package/dist/runtime/app/components/RequiplyDatePicker.d.ts +12 -0
- package/dist/runtime/app/components/RequiplyDatePicker.js +2 -0
- package/dist/runtime/app/components/RequiplyPortalButton.d.ts +34 -0
- package/dist/runtime/app/components/RequiplyPortalButton.js +6 -0
- package/dist/runtime/app/components/RequiplyPriceTiers.d.ts +21 -0
- package/dist/runtime/app/components/RequiplyPriceTiers.js +4 -0
- package/dist/runtime/app/components/RequiplyProduct.d.ts +37 -0
- package/dist/runtime/app/components/RequiplyProduct.js +26 -0
- package/dist/runtime/app/components/RequiplyProductCard.d.ts +21 -0
- package/dist/runtime/app/components/RequiplyProductCard.js +4 -0
- package/dist/runtime/app/components/RequiplyProductList.d.ts +70 -0
- package/dist/runtime/app/components/RequiplyProductList.js +19 -0
- package/dist/runtime/app/composables/useRequiply.d.ts +12 -0
- package/dist/runtime/app/composables/useRequiply.js +12 -0
- package/dist/runtime/app/composables/useRequiplyEmbed.d.ts +43 -0
- package/dist/runtime/app/composables/useRequiplyEmbed.js +54 -0
- package/dist/runtime/app/composables/useRequiplyProduct.d.ts +40 -0
- package/dist/runtime/app/composables/useRequiplyProduct.js +92 -0
- package/dist/runtime/app/embed.d.ts +79 -0
- package/dist/runtime/app/embed.js +75 -0
- package/dist/runtime/app/placeholder.d.ts +26 -0
- package/dist/runtime/app/placeholder.js +29 -0
- package/dist/runtime/app/plugins/requiply.d.ts +2 -0
- package/dist/runtime/app/plugins/requiply.js +46 -0
- package/dist/runtime/requiply.d.ts +2 -0
- package/dist/runtime/requiply.js +1 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/requiply.d.ts +16 -0
- package/dist/runtime/server/utils/requiply.js +22 -0
- package/dist/runtime/types.d.ts +221 -0
- package/dist/runtime/types.js +0 -0
- package/dist/types.d.mts +9 -0
- package/package.json +78 -4
package/README.md
CHANGED
|
@@ -1,3 +1,645 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://requiply.com">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Requiply/RequiplyNPM/main/packages/nuxt/docs/images/banner.webp" alt="Requiply for Nuxt: a date picker and two product cards with live prices, availability and Add to booking buttons" width="100%">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://npmjs.com/package/@requiply/nuxt"><img src="https://img.shields.io/npm/v/@requiply/nuxt/latest.svg?style=flat&colorA=1d1d1b&colorB=016e88" alt="npm version"></a>
|
|
9
|
+
<a href="https://npm.chart.dev/@requiply/nuxt"><img src="https://img.shields.io/npm/dm/@requiply/nuxt.svg?style=flat&colorA=1d1d1b&colorB=016e88" alt="npm downloads"></a>
|
|
10
|
+
<a href="https://github.com/Requiply/RequiplyNPM/blob/main/packages/nuxt/LICENSE"><img src="https://img.shields.io/npm/l/@requiply/nuxt.svg?style=flat&colorA=1d1d1b&colorB=016e88" alt="License"></a>
|
|
11
|
+
<a href="https://nuxt.com/modules/requiply"><img src="https://img.shields.io/badge/Nuxt-1d1d1b?logo=nuxt&logoColor=00DC82" alt="Nuxt"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://requiply.com">Requiply</a> ·
|
|
16
|
+
<a href="https://portal.requiply.com/stalford-studio-en">Demo booking page</a> ·
|
|
17
|
+
<a href="https://www.npmjs.com/package/@requiply/api-sdk">API SDK</a> ·
|
|
18
|
+
<a href="https://github.com/Zafiiovskiy/requiply-skills/tree/main/requiply-nuxt">Agent skill</a>
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
# Requiply for Nuxt
|
|
22
|
+
|
|
23
|
+
Build the website of a rental business on [Requiply](https://requiply.com) with Nuxt. Your pages show the catalog with live prices and availability for the visitor's dates; visitors fill a cart and check out in the Requiply booking portal, where the business already takes payments and confirms bookings. You keep full control of the design.
|
|
24
|
+
|
|
25
|
+
- **Booking widgets as Vue components.** `<RequiplyBookButton>`, `<RequiplyProductCard>`, `<RequiplyProductList>`, a date picker, a cart and more, server-rendered with SEO fallback and lined up in any grid out of the box.
|
|
26
|
+
- **Your own UI on top.** `<RequiplyProduct>` hands you the product, live availability and cart actions to render in your own markup. `useRequiplyEmbed()` drives the cart from your header or anywhere else.
|
|
27
|
+
- **Styled your way.** Design tokens, your own wording per language, CSS parts and injected CSS. The widgets take the business's brand color from Requiply until you say otherwise.
|
|
28
|
+
- **The Requiply API on both sides.** `useRequiply()` with a publishable key in pages and during SSR, `useRequiplyServer(event)` with a secret key in server routes for bookings, clients, sales and reports. The secret key never reaches the browser.
|
|
29
|
+
- **Typed end to end** with [`@requiply/api-sdk`](https://www.npmjs.com/package/@requiply/api-sdk).
|
|
30
|
+
|
|
31
|
+
## Contents
|
|
32
|
+
|
|
33
|
+
- [Quick start](#quick-start)
|
|
34
|
+
- [Components](#components)
|
|
35
|
+
- [Composables](#composables)
|
|
36
|
+
- [Customization](#customization)
|
|
37
|
+
- [Recipes](#recipes)
|
|
38
|
+
- [Configuration](#configuration)
|
|
39
|
+
- [API keys and security](#api-keys-and-security)
|
|
40
|
+
- [Coming from WordPress](#coming-from-wordpress)
|
|
41
|
+
- [Building with an AI coding agent](#building-with-an-ai-coding-agent)
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
**1. Install**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx nuxt module add @requiply/nuxt
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**2. Connect your booking page.** `org` is the end of your booking page address: `portal.requiply.com/my-rental` gives `my-rental`.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
// nuxt.config.ts
|
|
55
|
+
export default defineNuxtConfig({
|
|
56
|
+
modules: ['@requiply/nuxt'],
|
|
57
|
+
requiply: {
|
|
58
|
+
org: 'my-rental',
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**3. Add a booking button** to any page. Products are named by their slug, which Requiply shows under Settings > Integrations > Website embed ("Find a product slug").
|
|
64
|
+
|
|
65
|
+
```vue
|
|
66
|
+
<template>
|
|
67
|
+
<h1>Festival tent 6x12</h1>
|
|
68
|
+
<RequiplyBookButton item="festival-tent-6x12" />
|
|
69
|
+
</template>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
That is all the widgets need. To read the catalog in your own code (for example a server-rendered product page), add API keys from Requiply under Settings > API keys:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# .env
|
|
76
|
+
NUXT_PUBLIC_REQUIPLY_PUBLISHABLE_KEY=rq_pk_... # public, for useRequiply()
|
|
77
|
+
NUXT_REQUIPLY_SECRET_KEY=rq_sk_... # server only, for useRequiplyServer()
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Components
|
|
81
|
+
|
|
82
|
+
Every booking widget renders a placeholder that the Requiply widget runtime fills in a shadow root, so your CSS and theirs never clash. Anything you put inside a component is server-rendered fallback for search engines and visitors without JavaScript; the widget covers it once it loads. All of them are auto-imported.
|
|
83
|
+
|
|
84
|
+
<p align="center">
|
|
85
|
+
<img src="https://raw.githubusercontent.com/Requiply/RequiplyNPM/main/packages/nuxt/docs/images/widgets.webp" alt="A date picker above four product cards: camera, video switcher, microphone and projector, each with price, availability, quantity and Add to booking" width="100%">
|
|
86
|
+
</p>
|
|
87
|
+
<p align="center"><sub>Out of the box: the business's own color and corners from Requiply, nothing configured.</sub></p>
|
|
88
|
+
|
|
89
|
+
### `<RequiplyBookButton>`
|
|
90
|
+
|
|
91
|
+
Price, availability for the chosen dates, quantity and "Add to booking" for one product. Place it on a product page you designed yourself.
|
|
92
|
+
|
|
93
|
+
```vue
|
|
94
|
+
<RequiplyBookButton item="festival-tent-6x12">
|
|
95
|
+
<!-- server-rendered fallback -->
|
|
96
|
+
<a href="https://portal.requiply.com/my-rental">Festival tent 6x12, from $90 / day</a>
|
|
97
|
+
</RequiplyBookButton>
|
|
98
|
+
|
|
99
|
+
<!-- with a call button next to it -->
|
|
100
|
+
<RequiplyBookButton item="festival-tent-6x12" call="label" />
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
| Prop | Type | |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| `item` | `string` | Product slug. Required. |
|
|
106
|
+
| `call` | `boolean \| 'off' \| 'icon' \| 'label'` | Call button beside "Add to booking". Defaults to `embed.callButton`. |
|
|
107
|
+
|
|
108
|
+
### `<RequiplyProductCard>`
|
|
109
|
+
|
|
110
|
+
A complete card: photo, name, price, availability and "Add to booking". Cards placed side by side in your grid line up row by row.
|
|
111
|
+
|
|
112
|
+
```vue
|
|
113
|
+
<div class="grid">
|
|
114
|
+
<RequiplyProductCard
|
|
115
|
+
v-for="slug in ['festival-tent-6x12', 'dance-floor', 'led-uplight']"
|
|
116
|
+
:key="slug"
|
|
117
|
+
:item="slug"
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<style scoped>
|
|
122
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
|
|
123
|
+
</style>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
| Prop | Type | |
|
|
127
|
+
| --- | --- | --- |
|
|
128
|
+
| `item` | `string` | Product slug. Required. |
|
|
129
|
+
|
|
130
|
+
### `<RequiplyProductList>`
|
|
131
|
+
|
|
132
|
+
A grid of product cards with optional search, for a catalog page in one line.
|
|
133
|
+
|
|
134
|
+
```vue
|
|
135
|
+
<RequiplyProductList show-search :limit="24" />
|
|
136
|
+
|
|
137
|
+
<!-- one category (and its subcategories), products for sale included -->
|
|
138
|
+
<RequiplyProductList category="7c0e2c4e-6f1a-4d61-9b52-1f0d3c2a8e10" kind="all" />
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
| Prop | Type | |
|
|
142
|
+
| --- | --- | --- |
|
|
143
|
+
| `category` | `string` | Category id, from `useRequiply().categories.list()`. |
|
|
144
|
+
| `limit` | `number` | Most products to show. |
|
|
145
|
+
| `search` | `string` | Initial search text. |
|
|
146
|
+
| `showSearch` | `boolean` | Shows a search field above the grid. |
|
|
147
|
+
| `kind` | `'rental' \| 'sale' \| 'all'` | Rentals (default), products for sale, or both. |
|
|
148
|
+
|
|
149
|
+
### `<RequiplyDatePicker>`
|
|
150
|
+
|
|
151
|
+
The rental period field. It opens the date picker, which follows the business's working hours, buffers, minimum durations and availability. It fills the width of its container.
|
|
152
|
+
|
|
153
|
+
```vue
|
|
154
|
+
<section class="hero">
|
|
155
|
+
<h1>Event equipment, delivered</h1>
|
|
156
|
+
<div style="max-width: 560px"><RequiplyDatePicker /></div>
|
|
157
|
+
</section>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
<p align="center">
|
|
161
|
+
<img src="https://raw.githubusercontent.com/Requiply/RequiplyNPM/main/packages/nuxt/docs/images/dates.webp" alt="The date picker dialog: two months with the chosen days highlighted, and available pickup and return times" width="100%">
|
|
162
|
+
</p>
|
|
163
|
+
|
|
164
|
+
### `<RequiplyCartButton>`
|
|
165
|
+
|
|
166
|
+
A cart button with the unit count that opens the cart drawer. Placing one hides the floating cart button.
|
|
167
|
+
|
|
168
|
+
```vue
|
|
169
|
+
<header>
|
|
170
|
+
<NuxtLink to="/">Acme Rentals</NuxtLink>
|
|
171
|
+
<RequiplyCartButton label="Booking" />
|
|
172
|
+
</header>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
| Prop | Type | |
|
|
176
|
+
| --- | --- | --- |
|
|
177
|
+
| `label` | `string` | Button text. Defaults to "Your booking" in the visitor's language. |
|
|
178
|
+
|
|
179
|
+
<p align="center">
|
|
180
|
+
<img src="https://raw.githubusercontent.com/Requiply/RequiplyNPM/main/packages/nuxt/docs/images/cart.webp" alt="The cart drawer open over the catalog: dates, two products with quantities, subtotal, deposit, total and Continue to checkout" width="100%">
|
|
181
|
+
</p>
|
|
182
|
+
<p align="center"><sub>The cart: dates, lines, add-on services and totals, then checkout in the booking portal.</sub></p>
|
|
183
|
+
|
|
184
|
+
### `<RequiplyPriceTiers>`
|
|
185
|
+
|
|
186
|
+
The price per rental length when the business gives discounts for longer rentals.
|
|
187
|
+
|
|
188
|
+
```vue
|
|
189
|
+
<RequiplyPriceTiers item="festival-tent-6x12" />
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
| Prop | Type | |
|
|
193
|
+
| --- | --- | --- |
|
|
194
|
+
| `item` | `string` | Product slug. Required. |
|
|
195
|
+
|
|
196
|
+
### `<RequiplyBundle>`
|
|
197
|
+
|
|
198
|
+
A kit (bundle) card with its parts, price and "Add to booking", including kits where the visitor picks options.
|
|
199
|
+
|
|
200
|
+
```vue
|
|
201
|
+
<RequiplyBundle bundle="6b1f0c9e-2d7a-4b3e-9c55-0e1f2a3b4c5d" />
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
| Prop | Type | |
|
|
205
|
+
| --- | --- | --- |
|
|
206
|
+
| `bundle` | `string` | Bundle id, from `useRequiply().bundles.list()`. Required. |
|
|
207
|
+
|
|
208
|
+
### `<RequiplyPortalButton>`
|
|
209
|
+
|
|
210
|
+
"Book online": checkout with the cart, or the booking page when the cart is empty.
|
|
211
|
+
|
|
212
|
+
```vue
|
|
213
|
+
<RequiplyPortalButton label="Book now" />
|
|
214
|
+
<RequiplyPortalButton ghost />
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
| Prop | Type | |
|
|
218
|
+
| --- | --- | --- |
|
|
219
|
+
| `label` | `string` | Button text. |
|
|
220
|
+
| `ghost` | `boolean` | Outlined instead of filled. |
|
|
221
|
+
|
|
222
|
+
### `<RequiplyAccountLinks>`
|
|
223
|
+
|
|
224
|
+
"Sign in" and "Register" to the customer's booking portal account; once signed in, their initials linking to the account.
|
|
225
|
+
|
|
226
|
+
```vue
|
|
227
|
+
<RequiplyAccountLinks hide-register />
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
| Prop | Type | |
|
|
231
|
+
| --- | --- | --- |
|
|
232
|
+
| `loginLabel`, `registerLabel` | `string` | Link texts. |
|
|
233
|
+
| `hideRegister` | `boolean` | Only "Sign in". |
|
|
234
|
+
| `showName` | `boolean` | The customer's first name next to the initials. |
|
|
235
|
+
|
|
236
|
+
### `<RequiplyCallButton>`
|
|
237
|
+
|
|
238
|
+
Opens the call window with your phone numbers (`embed.phones`, else the business's phone) and working hours.
|
|
239
|
+
|
|
240
|
+
```vue
|
|
241
|
+
<RequiplyCallButton />
|
|
242
|
+
<RequiplyCallButton icon-only />
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
| Prop | Type | |
|
|
246
|
+
| --- | --- | --- |
|
|
247
|
+
| `label` | `string` | Button text. |
|
|
248
|
+
| `iconOnly` | `boolean` | The phone icon alone. |
|
|
249
|
+
|
|
250
|
+
### `<RequiplyProduct>`: your own markup
|
|
251
|
+
|
|
252
|
+
Renders nothing itself: it hands its slot the product and the cart actions, and the widgets keep handling dates, the cart drawer and checkout. The product is server-rendered from the public catalog (all `<RequiplyProduct>` of a page in one request); availability for the chosen dates, the formatted price and the cart quantity arrive once the widgets load.
|
|
253
|
+
|
|
254
|
+
<p align="center">
|
|
255
|
+
<img src="https://raw.githubusercontent.com/Requiply/RequiplyNPM/main/packages/nuxt/docs/images/headless.webp" alt="Four dark custom product cards built with RequiplyProduct: category, name, price, availability for the dates, and a Rent button or an in-booking stepper" width="100%">
|
|
256
|
+
</p>
|
|
257
|
+
|
|
258
|
+
```vue
|
|
259
|
+
<script setup lang="ts">
|
|
260
|
+
const { data } = await useAsyncData('shop', () => useRequiply().inventory.list({ limit: 8 }))
|
|
261
|
+
</script>
|
|
262
|
+
|
|
263
|
+
<template>
|
|
264
|
+
<div class="grid">
|
|
265
|
+
<RequiplyProduct
|
|
266
|
+
v-for="item in data?.items ?? []"
|
|
267
|
+
:key="item.id"
|
|
268
|
+
v-slot="{ product, ready, price, hasDates, available, soldOut, inCart, add, setQuantity }"
|
|
269
|
+
:item="item.slug ?? item.id"
|
|
270
|
+
>
|
|
271
|
+
<article v-if="product" class="card">
|
|
272
|
+
<div class="card__img">
|
|
273
|
+
<img v-if="product.imageUrl" :src="product.imageUrl" :alt="product.name">
|
|
274
|
+
</div>
|
|
275
|
+
<h3 class="card__name">{{ product.name }}</h3>
|
|
276
|
+
<div class="card__foot">
|
|
277
|
+
<p>{{ price ?? `${product.price} ${item.currency}` }} / {{ product.priceType }}</p>
|
|
278
|
+
<!-- always rendered, so cards keep one height -->
|
|
279
|
+
<p class="card__status">
|
|
280
|
+
{{ ready && hasDates && available !== null ? `${available} free on your dates` : '\u00a0' }}
|
|
281
|
+
</p>
|
|
282
|
+
<div v-if="inCart" class="card__action card__qty">
|
|
283
|
+
<button @click="setQuantity(inCart - 1)">−</button><span>{{ inCart }}</span>
|
|
284
|
+
<button
|
|
285
|
+
:disabled="available !== null && inCart >= available"
|
|
286
|
+
@click="setQuantity(inCart + 1)"
|
|
287
|
+
>+</button>
|
|
288
|
+
</div>
|
|
289
|
+
<button v-else class="card__action" :disabled="!ready || soldOut" @click="add()">Rent</button>
|
|
290
|
+
</div>
|
|
291
|
+
</article>
|
|
292
|
+
</RequiplyProduct>
|
|
293
|
+
</div>
|
|
294
|
+
</template>
|
|
295
|
+
|
|
296
|
+
<style scoped>
|
|
297
|
+
/* Rows line up: the card fills its cell, image and name take fixed space,
|
|
298
|
+
the footer sits at the bottom. */
|
|
299
|
+
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
|
|
300
|
+
.card { box-sizing: border-box; height: 100%; display: flex; flex-direction: column; gap: 8px; }
|
|
301
|
+
.card__img { aspect-ratio: 4 / 3; overflow: hidden; }
|
|
302
|
+
.card__img img { display: block; width: 100%; height: 100%; object-fit: contain; }
|
|
303
|
+
.card__name {
|
|
304
|
+
margin: 0; line-height: 1.3; height: calc(2 * 1.3em); /* two lines, fixed */
|
|
305
|
+
overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
|
|
306
|
+
}
|
|
307
|
+
.card__foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
|
|
308
|
+
.card__status { margin: 0; min-height: 1.4em; }
|
|
309
|
+
.card__action { box-sizing: border-box; height: 42px; width: 100%; }
|
|
310
|
+
.card__qty { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; }
|
|
311
|
+
</style>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Slot values: `product` (`id`, `name`, `slug`, `kind`, `price`, `priceType`, `depositAmount`, `description`, `imageUrl`, `images`, `categoryId`, `categoryName`, `pricingTiers`, `properties`, `totalQuantity`, `availableQuantity`, `unlimited`), `pending`, `ready`, `price` (formatted), `hasDates`, `available`, `soldOut`, `inCart`, `add(quantity?)`, `setQuantity(quantity)` and `remove()`.
|
|
315
|
+
|
|
316
|
+
## Composables
|
|
317
|
+
|
|
318
|
+
### `useRequiply()`
|
|
319
|
+
|
|
320
|
+
The [`@requiply/api-sdk`](https://www.npmjs.com/package/@requiply/api-sdk) client with the publishable key, for pages and components, in the browser and during SSR. It reads the organization, categories, services, catalog, kits, availability and prices, and sends booking requests.
|
|
321
|
+
|
|
322
|
+
```vue
|
|
323
|
+
<script setup lang="ts">
|
|
324
|
+
const requiply = useRequiply()
|
|
325
|
+
const { data: categories } = await useAsyncData('categories', () => requiply.categories.list())
|
|
326
|
+
const { data: tents } = await useAsyncData('tents', () =>
|
|
327
|
+
requiply.inventory.list({ search: 'tent', limit: 12 }))
|
|
328
|
+
</script>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### `useRequiplyEmbed()`
|
|
332
|
+
|
|
333
|
+
The visitor's cart as reactive state, and the widget actions, for your own cart button, "Book" links or a dates field.
|
|
334
|
+
|
|
335
|
+
```vue
|
|
336
|
+
<script setup lang="ts">
|
|
337
|
+
const { ready, count, openCart, addToCart, setDates, checkout } = useRequiplyEmbed()
|
|
338
|
+
</script>
|
|
339
|
+
|
|
340
|
+
<template>
|
|
341
|
+
<button :disabled="!ready" @click="openCart">Cart ({{ count }})</button>
|
|
342
|
+
<button @click="addToCart('festival-tent-6x12')">Book this tent</button>
|
|
343
|
+
</template>
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
| Returns | |
|
|
347
|
+
| --- | --- |
|
|
348
|
+
| `ready` | True once the widgets loaded, right after hydration. |
|
|
349
|
+
| `cart`, `count` | Items, kits, products for sale, services, dates and the unit count. Empty on the server. |
|
|
350
|
+
| `addToCart(slugOrId, quantity?)` | Adds like "Add to booking": asks for dates first when the business starts bookings from dates, then opens the cart. |
|
|
351
|
+
| `setQuantity(id, n)`, `remove(id)`, `clear()` | Change the cart. |
|
|
352
|
+
| `setDates(start, end)` | ISO date-times in the business's time zone, or `null`s. |
|
|
353
|
+
| `openCart()`, `openDatePicker()`, `openCall()` | Open the drawers and dialogs. |
|
|
354
|
+
| `checkout()` | Checkout in the booking portal with the cart. |
|
|
355
|
+
| `whenReady()` | The widget runtime once loaded, for anything else. |
|
|
356
|
+
|
|
357
|
+
### `useRequiplyProduct(item)`
|
|
358
|
+
|
|
359
|
+
The script form of `<RequiplyProduct>`, for a product page in your own markup.
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
const route = useRoute()
|
|
363
|
+
const { product, price, available, inCart, add } = useRequiplyProduct(() => String(route.params.slug))
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### `useRequiplyServer(event)`
|
|
367
|
+
|
|
368
|
+
The client with the secret key, auto-imported in `server/`. It reaches everything the API allows: bookings, clients, sales, inventory edits and reports.
|
|
369
|
+
|
|
370
|
+
```ts
|
|
371
|
+
// server/api/owner/summary.get.ts
|
|
372
|
+
export default defineEventHandler(async (event) => {
|
|
373
|
+
await requireOwner(event) // your own auth: the secret key acts as the whole business
|
|
374
|
+
const report = await useRequiplyServer(event).reports.revenue({ groupBy: 'month' })
|
|
375
|
+
// Return only what the page needs. Money is in major units of report.currency.
|
|
376
|
+
return {
|
|
377
|
+
revenue: report.totals.totalRevenue,
|
|
378
|
+
bookings: report.totals.bookingCount,
|
|
379
|
+
currency: report.currency,
|
|
380
|
+
}
|
|
381
|
+
})
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Errors are `RequiplyError` (auto-imported in `server/`) with `status`, `reason` and `data`. Types come from `#requiply`:
|
|
385
|
+
|
|
386
|
+
```ts
|
|
387
|
+
import type { InventoryItem, RequiplyCart, RequiplyProduct } from '#requiply'
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Customization
|
|
391
|
+
|
|
392
|
+
Four levels, from a color change to your own markup. Mix them freely.
|
|
393
|
+
|
|
394
|
+
<p align="center">
|
|
395
|
+
<img src="https://raw.githubusercontent.com/Requiply/RequiplyNPM/main/packages/nuxt/docs/images/themed.webp" alt="The same four product cards restyled: teal buttons with uppercase labels, square corners and Inter type" width="100%">
|
|
396
|
+
</p>
|
|
397
|
+
<p align="center"><sub>The cards from the top of this page, restyled with a few tokens and three CSS parts.</sub></p>
|
|
398
|
+
|
|
399
|
+
**1. Design tokens.** Written to `:root` as `--rq-*` variables, so you can just as well set them in your own CSS, per page or per element.
|
|
400
|
+
|
|
401
|
+
```ts
|
|
402
|
+
requiply: {
|
|
403
|
+
embed: {
|
|
404
|
+
theme: {
|
|
405
|
+
primary: '#016e88', // also derives the text on it, links and shades
|
|
406
|
+
font: 'Inter, sans-serif',
|
|
407
|
+
radiusCard: '4px',
|
|
408
|
+
radiusControl: '2px',
|
|
409
|
+
controlHeight: '44px', // buttons, fields, steppers
|
|
410
|
+
border: '#e4e7eb',
|
|
411
|
+
range: '#016e88', // chosen days in the date picker
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
```css
|
|
418
|
+
/* the same from CSS, for example a dark section */
|
|
419
|
+
.dark { --rq-surface: #111827; --rq-text: #f3f4f6; --rq-border: rgba(255, 255, 255, .12); }
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
All tokens: `primary`, `onPrimary`, `link`, `font`, `fontSize`, `text`, `surface`, `mutedBg`, `border`, `inputBorder`, `controlHeight`, `radiusCard`, `radiusControl`, `radiusPill`, `radiusImage`, `success`, `successBg`, `danger`, `range`, `rangeSoft`, `onRange`, `overlay`.
|
|
423
|
+
|
|
424
|
+
**2. Your own wording**, for every language or per language:
|
|
425
|
+
|
|
426
|
+
```ts
|
|
427
|
+
embed: {
|
|
428
|
+
messages: {
|
|
429
|
+
add: 'Rent it', // every language
|
|
430
|
+
uk: { add: 'Орендувати' }, // one language, wins over the line above
|
|
431
|
+
},
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Common keys: `add`, `buy`, `inCart`, `chooseDates`, `checkAvailability`, `availableCount` (`{n} available`), `unavailable`, `cartTitle`, `checkout`, `bookOnline`, `login`, `register`.
|
|
436
|
+
|
|
437
|
+
**3. CSS parts.** Every element inside a widget is a [CSS part](https://developer.mozilla.org/docs/Web/CSS/::part) named after its class without the `rq-` prefix, usable from any stylesheet, Vue scoped styles included:
|
|
438
|
+
|
|
439
|
+
```css
|
|
440
|
+
.requiply-card::part(btn) { text-transform: uppercase; letter-spacing: .06em; }
|
|
441
|
+
.requiply-card::part(card__name) { font-size: 14px; }
|
|
442
|
+
.requiply-button::part(price__amount) { color: #016e88; }
|
|
443
|
+
[data-requiply="cart"]::part(drawer) { width: 480px; }
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
For what parts cannot express (descendants, states), add CSS inside every widget, the cart and dialogs included:
|
|
447
|
+
|
|
448
|
+
```ts
|
|
449
|
+
embed: {
|
|
450
|
+
css: '.rq-btn:hover:not(:disabled) { filter: none; background: #015a70; }',
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**4. Your own markup** with [`<RequiplyProduct>`](#requiplyproduct-your-own-markup).
|
|
455
|
+
|
|
456
|
+
## Recipes
|
|
457
|
+
|
|
458
|
+
### Product page with SEO
|
|
459
|
+
|
|
460
|
+
```vue
|
|
461
|
+
<!-- app/pages/products/[slug].vue -->
|
|
462
|
+
<script setup lang="ts">
|
|
463
|
+
const route = useRoute()
|
|
464
|
+
const slug = computed(() => String(route.params.slug))
|
|
465
|
+
const requiply = useRequiply()
|
|
466
|
+
|
|
467
|
+
const { data: product } = await useAsyncData(() => `product-${slug.value}`, async () => {
|
|
468
|
+
const found = (await requiply.inventory.list({ slugs: [slug.value] })).items[0]
|
|
469
|
+
return found ? (await requiply.inventory.getGroup(found.id)).itemGroup : null
|
|
470
|
+
})
|
|
471
|
+
if (!product.value) {
|
|
472
|
+
throw createError({ statusCode: 404, statusMessage: 'Product not found', fatal: true })
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const images = computed(() => product.value?.images ?? [])
|
|
476
|
+
const image = computed(() => (images.value.find(i => i.isDefault) ?? images.value[0])?.url)
|
|
477
|
+
// Descriptions are multi-line plain text: one line of about 160 characters for search engines.
|
|
478
|
+
const summary = computed(() => product.value?.description?.replace(/\s+/g, ' ').trim().slice(0, 160))
|
|
479
|
+
useSeoMeta({
|
|
480
|
+
title: () => product.value?.name,
|
|
481
|
+
description: () => summary.value,
|
|
482
|
+
ogImage: () => image.value,
|
|
483
|
+
})
|
|
484
|
+
</script>
|
|
485
|
+
|
|
486
|
+
<template>
|
|
487
|
+
<article>
|
|
488
|
+
<img v-if="image" :src="image" :alt="product?.name">
|
|
489
|
+
<h1>{{ product?.name }}</h1>
|
|
490
|
+
<p style="white-space: pre-line">{{ product?.description }}</p>
|
|
491
|
+
<RequiplyBookButton :item="slug">
|
|
492
|
+
<p>{{ product?.basePrice }} {{ product?.currency }} / {{ product?.priceType }}</p>
|
|
493
|
+
</RequiplyBookButton>
|
|
494
|
+
<RequiplyPriceTiers :item="slug" />
|
|
495
|
+
</article>
|
|
496
|
+
</template>
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
### Header with your own cart button
|
|
500
|
+
|
|
501
|
+
```vue
|
|
502
|
+
<script setup lang="ts">
|
|
503
|
+
const { ready, count, openCart } = useRequiplyEmbed()
|
|
504
|
+
</script>
|
|
505
|
+
|
|
506
|
+
<template>
|
|
507
|
+
<header class="site-header">
|
|
508
|
+
<NuxtLink to="/">Acme Rentals</NuxtLink>
|
|
509
|
+
<RequiplyAccountLinks hide-register />
|
|
510
|
+
<button type="button" :disabled="!ready" @click="openCart">
|
|
511
|
+
Booking <span>{{ count }}</span>
|
|
512
|
+
</button>
|
|
513
|
+
</header>
|
|
514
|
+
</template>
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
Set `embed: { floatingCart: false }` when your own button replaces the floating one.
|
|
518
|
+
|
|
519
|
+
### Booking request from your own form
|
|
520
|
+
|
|
521
|
+
The cart and portal checkout cover most sites. When a form of your own is required:
|
|
522
|
+
|
|
523
|
+
```ts
|
|
524
|
+
const result = await useRequiply().bookings.create({
|
|
525
|
+
startDate: '2026-07-01T09:00', // the business's time zone, within working hours
|
|
526
|
+
endDate: '2026-07-03T18:00',
|
|
527
|
+
items: [{ groupId: product.id, quantity: 1 }],
|
|
528
|
+
deliveryType: 'pickup',
|
|
529
|
+
asRequest: true, // staff approve it in Requiply
|
|
530
|
+
client: { name, email, phone },
|
|
531
|
+
})
|
|
532
|
+
if (!result.success) {
|
|
533
|
+
// result.reason: 'unavailable', 'working_hours' or 'minimum_duration'
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
## Configuration
|
|
538
|
+
|
|
539
|
+
```ts
|
|
540
|
+
// nuxt.config.ts
|
|
541
|
+
export default defineNuxtConfig({
|
|
542
|
+
modules: ['@requiply/nuxt'],
|
|
543
|
+
requiply: {
|
|
544
|
+
org: 'my-rental',
|
|
545
|
+
embed: {
|
|
546
|
+
floatingCart: true,
|
|
547
|
+
cartPosition: 'right',
|
|
548
|
+
phones: [{ number: '+15551234567', label: 'Rentals desk' }],
|
|
549
|
+
callButton: 'icon',
|
|
550
|
+
theme: { primary: '#016e88' },
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
})
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
| Option | Env variable | Default | |
|
|
557
|
+
| --- | --- | --- | --- |
|
|
558
|
+
| `org` | `NUXT_PUBLIC_REQUIPLY_ORG` | | Booking page code. Needed by the widgets. |
|
|
559
|
+
| `publishableKey` | `NUXT_PUBLIC_REQUIPLY_PUBLISHABLE_KEY` | | `rq_pk_...` for `useRequiply()`. |
|
|
560
|
+
| `secretKey` | `NUXT_REQUIPLY_SECRET_KEY` | | `rq_sk_...` for `useRequiplyServer()`. Use the env variable. |
|
|
561
|
+
| `apiUrl` | `NUXT_PUBLIC_REQUIPLY_API_URL` | `https://api.requiply.com` | |
|
|
562
|
+
| `portalUrl` | `NUXT_PUBLIC_REQUIPLY_PORTAL_URL` | `https://portal.requiply.com` | |
|
|
563
|
+
| `embed` | | `true` | Widget options below, or `false` for an API-only site. |
|
|
564
|
+
| `components` | | `true` | Registers the `<Requiply*>` components. |
|
|
565
|
+
|
|
566
|
+
| `embed` option | Values | Default |
|
|
567
|
+
| --- | --- | --- |
|
|
568
|
+
| `locale` | `en`, `uk`, `es`, `pl` | `<html lang>`, then the business's language |
|
|
569
|
+
| `color` | hex | the booking page color |
|
|
570
|
+
| `corners` | `sharp`, `soft`, `rounded` | the booking page setting |
|
|
571
|
+
| `floatingCart` | boolean | `true` |
|
|
572
|
+
| `cartPosition` | `right`, `left` | `right` |
|
|
573
|
+
| `currencyDisplay` | `symbol`, `code` | `symbol` |
|
|
574
|
+
| `startFrom` | `items`, `dates` | the business's booking setting |
|
|
575
|
+
| `returnUrl`, `siteUrl` | URL | the page booked from, the site origin |
|
|
576
|
+
| `phones` | `string[]` or `{ number, label }[]` | the business's phone |
|
|
577
|
+
| `callButton` | `off`, `icon`, `label` | `off` |
|
|
578
|
+
| `callFloating` | `off`, `mobile`, `all` | `off` |
|
|
579
|
+
| `callNote`, `callHours` | text, boolean | none, `true` |
|
|
580
|
+
| `cartIcon` | `cart`, `calendar`, `truck`, `none` | `calendar` |
|
|
581
|
+
| `buttonIcon` | `cart`, `calendar`, `truck`, `plus`, `none` | `plus` |
|
|
582
|
+
| `iconStyle` | `outline`, `filled` | `outline` |
|
|
583
|
+
| `theme`, `messages`, `css` | see [Customization](#customization) | |
|
|
584
|
+
| `scriptUrl` | URL | `<portalUrl>/embed/v1/requiply-embed.js` |
|
|
585
|
+
|
|
586
|
+
## API keys and security
|
|
587
|
+
|
|
588
|
+
| | Publishable key `rq_pk_` | Secret key `rq_sk_` |
|
|
589
|
+
| --- | --- | --- |
|
|
590
|
+
| Where | `useRequiply()`, anywhere | `useRequiplyServer(event)`, `server/` only |
|
|
591
|
+
| Stored in | public runtime config (it is printed into pages, by design) | private runtime config |
|
|
592
|
+
| Reaches | organization, categories, services, catalog, kits, availability, prices, booking requests | everything, including bookings, clients, sales, inventory edits and reports |
|
|
593
|
+
|
|
594
|
+
- The module refuses to build, and to render, when a secret key is put where the publishable one goes.
|
|
595
|
+
- Products and services the business hides from clients never reach a publishable key or the widgets.
|
|
596
|
+
- Put your own authentication in front of every server route that uses the secret key, and return only the fields the page needs.
|
|
597
|
+
|
|
598
|
+
## Coming from WordPress
|
|
599
|
+
|
|
600
|
+
The components are the [Requiply WordPress plugin](https://wordpress.org/plugins/requiply-rental-booking/)'s shortcodes, and carts and checkout work the same way:
|
|
601
|
+
|
|
602
|
+
| WordPress shortcode | Nuxt |
|
|
603
|
+
| --- | --- |
|
|
604
|
+
| `[requiply_button id="..."]` | `<RequiplyBookButton item="..." />` |
|
|
605
|
+
| `[requiply_card id="..."]` | `<RequiplyProductCard item="..." />` |
|
|
606
|
+
| `[requiply_list]` | `<RequiplyProductList />` |
|
|
607
|
+
| `[requiply_datepicker]` | `<RequiplyDatePicker />` |
|
|
608
|
+
| `[requiply_cart_button]` | `<RequiplyCartButton />` |
|
|
609
|
+
| `[requiply_account_links]` | `<RequiplyAccountLinks />` |
|
|
610
|
+
|
|
611
|
+
## Building with an AI coding agent
|
|
612
|
+
|
|
613
|
+
The [`requiply-nuxt` agent skill](https://github.com/Zafiiovskiy/requiply-skills/tree/main/requiply-nuxt) teaches Claude Code and other agents this module: key safety, which component fits which page, SEO product pages, aligned custom cards, theming, and how to check the result. Copy the folder into your project's `.claude/skills/`.
|
|
614
|
+
|
|
615
|
+
## Development
|
|
616
|
+
|
|
617
|
+
```bash
|
|
618
|
+
# from the repository root
|
|
619
|
+
npm install
|
|
620
|
+
|
|
621
|
+
# in packages/nuxt
|
|
622
|
+
npm run dev:prepare # stub build and types
|
|
623
|
+
npm run dev # playground
|
|
624
|
+
npm run lint
|
|
625
|
+
npm run test
|
|
626
|
+
npm run test:types
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
The playground reads `playground/.env` (see `.env.example`). `REQUIPLY_ORG`, `REQUIPLY_API_URL` and `REQUIPLY_PORTAL_URL` point it at another booking page; `REQUIPLY_PLAYGROUND_THEME=off` shows the widgets without the demo theme, and `/showcase` renders the images in this README.
|
|
630
|
+
|
|
631
|
+
## License
|
|
632
|
+
|
|
633
|
+
[MIT](https://github.com/Requiply/RequiplyNPM/blob/main/packages/nuxt/LICENSE)
|
|
634
|
+
|
|
635
|
+
<br>
|
|
636
|
+
|
|
637
|
+
<p align="center">
|
|
638
|
+
<a href="https://requiply.com">
|
|
639
|
+
<picture>
|
|
640
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Requiply/RequiplyNPM/main/packages/nuxt/docs/images/requiply-logo-white.svg">
|
|
641
|
+
<img src="https://raw.githubusercontent.com/Requiply/RequiplyNPM/main/packages/nuxt/docs/images/requiply-logo.svg" alt="Requiply" height="36">
|
|
642
|
+
</picture>
|
|
643
|
+
</a>
|
|
644
|
+
</p>
|
|
645
|
+
<p align="center"><sub>Rental and booking management for equipment, event, construction and sports rental businesses.</sub></p>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { RequiplyPublicRuntimeConfig, RequiplyPrivateRuntimeConfig, ModuleOptions } from '../dist/runtime/types.js';
|
|
3
|
+
export * from '../dist/runtime/types.js';
|
|
4
|
+
|
|
5
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
6
|
+
|
|
7
|
+
declare module '@nuxt/schema' {
|
|
8
|
+
interface PublicRuntimeConfig {
|
|
9
|
+
requiply: RequiplyPublicRuntimeConfig;
|
|
10
|
+
}
|
|
11
|
+
interface RuntimeConfig {
|
|
12
|
+
requiply: RequiplyPrivateRuntimeConfig;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { _default as default };
|