@cartbase/storefront 0.6.0 → 0.8.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 +74 -58
- package/package.json +248 -233
- package/src/api/carts.ts +16 -1
- package/src/api/http.ts +17 -9
- package/src/api/index.ts +1 -0
- package/src/api/integrations.ts +118 -117
- package/src/api/store.ts +35 -0
- package/src/checkout/geocode.ts +1 -1
- package/src/lib/cookie-names.ts +45 -0
- package/src/lib/platform.ts +13 -0
- package/src/lib/visitor.ts +74 -0
- package/src/tracking/attribution.ts +153 -11
- package/src/tracking/consent.ts +14 -0
- package/src/tracking/events.ts +294 -0
- package/src/tracking/ga4.tsx +93 -49
- package/src/tracking/get-tracking-attribution.ts +46 -3
- package/src/tracking/google-ads.ts +84 -0
- package/src/tracking/gtag.ts +26 -13
- package/src/tracking/gtm.tsx +60 -0
- package/src/tracking/index.ts +187 -133
- package/src/tracking/inline-script.ts +49 -0
- package/src/tracking/live-heartbeat.tsx +63 -0
- package/src/tracking/page-views.tsx +96 -0
- package/src/tracking/storefront-tags.tsx +75 -0
- package/src/tracking/tiktok-pixel.tsx +83 -0
- package/src/tracking/track-init.tsx +56 -0
- package/src/tracking/track-order-purchase.tsx +122 -0
- package/src/tracking/ttq.ts +180 -0
- package/src/tracking/types.ts +23 -0
- package/src/tracking/use-tracking-config.ts +54 -0
package/README.md
CHANGED
|
@@ -1,58 +1,74 @@
|
|
|
1
|
-
# @cartbase/storefront
|
|
2
|
-
|
|
3
|
-
The storefront kit for the [Cartbase](https://cartbase.net) commerce
|
|
4
|
-
platform: a fully-typed API client for every store endpoint, checkout
|
|
5
|
-
orchestration, a production-grade cart drawer, product and catalog
|
|
6
|
-
components, and consent-gated tracking — everything a storefront needs
|
|
7
|
-
between your pages and your store.
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm create cartbase my-store # scaffold with everything prewired
|
|
11
|
-
# or add to an existing Next.js app:
|
|
12
|
-
npm install @cartbase/storefront
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Setup
|
|
16
|
-
|
|
17
|
-
The package is **source-shipped TypeScript** — tell Next.js to compile it:
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
// next.config.js
|
|
21
|
-
module.exports = {
|
|
22
|
-
transpilePackages: ["@cartbase/storefront"],
|
|
23
|
-
}
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
admin
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| `@cartbase/storefront/
|
|
40
|
-
| `@cartbase/storefront/
|
|
41
|
-
| `@cartbase/storefront/
|
|
42
|
-
| `@cartbase/storefront/
|
|
43
|
-
| `@cartbase/storefront/
|
|
44
|
-
| `@cartbase/storefront/
|
|
45
|
-
| `@cartbase/storefront/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
1
|
+
# @cartbase/storefront
|
|
2
|
+
|
|
3
|
+
The storefront kit for the [Cartbase](https://cartbase.net) commerce
|
|
4
|
+
platform: a fully-typed API client for every store endpoint, checkout
|
|
5
|
+
orchestration, a production-grade cart drawer, product and catalog
|
|
6
|
+
components, and consent-gated tracking — everything a storefront needs
|
|
7
|
+
between your pages and your store.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm create cartbase my-store # scaffold with everything prewired
|
|
11
|
+
# or add to an existing Next.js app:
|
|
12
|
+
npm install @cartbase/storefront
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Setup
|
|
16
|
+
|
|
17
|
+
The package is **source-shipped TypeScript** — tell Next.js to compile it:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
// next.config.js
|
|
21
|
+
module.exports = {
|
|
22
|
+
transpilePackages: ["@cartbase/storefront"],
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
One environment value wires it to your store: the publishable key your
|
|
27
|
+
Cartbase admin hands out on the **Storefront** page.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
NEXT_PUBLIC_CARTBASE_PUBLISHABLE_KEY= # your store's key: names the store, scopes the catalog
|
|
31
|
+
NEXT_PUBLIC_CARTBASE_URL= # optional: only to point at a local or staging platform
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## What's inside
|
|
35
|
+
|
|
36
|
+
| Import | What you get |
|
|
37
|
+
|---|---|
|
|
38
|
+
| `@cartbase/storefront/api` | Typed client for the whole store API — products, carts, checkout, orders, customers, auth, content, search, reviews |
|
|
39
|
+
| `@cartbase/storefront/checkout` | The complete checkout: orchestration hook, address forms, shipping/payment method lists, Stripe wrapper, carrier pickers |
|
|
40
|
+
| `@cartbase/storefront/cart-drawer` | Slide-out cart with upsells, tiers, gift options, notes |
|
|
41
|
+
| `@cartbase/storefront/products` | PDP building blocks: gallery, options, prices, actions |
|
|
42
|
+
| `@cartbase/storefront/store` | Listing pages: pagination, sorting, collection/category/search templates |
|
|
43
|
+
| `@cartbase/storefront/order` | Order confirmation surfaces |
|
|
44
|
+
| `@cartbase/storefront/tracking` | Consent banner and Consent Mode v2, every marketing tag the store configured mounted from its own config (Meta Pixel, TikTok, Google Analytics 4 and Google Ads on one tag, Google Tag Manager), and one call per commerce moment that fires all of them |
|
|
45
|
+
| `@cartbase/storefront/theme` | The design system: token names plus a filled default set of values (Tailwind 4, CSS-first) |
|
|
46
|
+
|
|
47
|
+
### Tracking, in three lines
|
|
48
|
+
|
|
49
|
+
The merchant configures their pixels in the admin; the storefront mounts
|
|
50
|
+
what they configured. Nothing per vendor:
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
<ConsentInit /> // first child of <body>, sets the consent defaults
|
|
54
|
+
<StorefrontTags client={client} /> // every configured tag, gated by the above
|
|
55
|
+
<TrackInit /> // captures UTMs + ad-click ids on the landing page
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Then one call per moment (`trackProductView`, `trackCartAdd`,
|
|
59
|
+
`trackCheckoutStart`) and `<TrackOrderPurchase>` on the confirmation
|
|
60
|
+
page. Purchase events dedupe against the platform's own server-side
|
|
61
|
+
events automatically — the ids are derived from the order number on both
|
|
62
|
+
sides, so the browser event and the server event count as one conversion.
|
|
63
|
+
|
|
64
|
+
## Documentation
|
|
65
|
+
|
|
66
|
+
The complete reference — every endpoint with request/response shapes and
|
|
67
|
+
working examples, plus a step-by-step build runbook — is written to be
|
|
68
|
+
followed by a developer **or handed to a coding agent as-is**. It ships
|
|
69
|
+
inside every `npm create cartbase` scaffold under `docs/`, and online at
|
|
70
|
+
your store's docs site. Start with *Build a storefront — the runbook*.
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT © Cartbase
|