@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 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
- Three environment values wire it to your store (all in your Cartbase
27
- admin under **Settings**):
28
-
29
- ```bash
30
- NEXT_PUBLIC_CARTBASE_URL= # your store's API origin
31
- NEXT_PUBLIC_CARTBASE_CLIENT_ID= # your store's client id
32
- NEXT_PUBLIC_CARTBASE_PUBLISHABLE_KEY= # optional, channel-scoped catalogs
33
- ```
34
-
35
- ## What's inside
36
-
37
- | Import | What you get |
38
- |---|---|
39
- | `@cartbase/storefront/api` | Typed client for the whole store API — products, carts, checkout, orders, customers, auth, content, search, reviews |
40
- | `@cartbase/storefront/checkout` | The complete checkout: orchestration hook, address forms, shipping/payment method lists, Stripe wrapper, carrier pickers |
41
- | `@cartbase/storefront/cart-drawer` | Slide-out cart with upsells, tiers, gift options, notes |
42
- | `@cartbase/storefront/products` | PDP building blocks: gallery, options, prices, actions |
43
- | `@cartbase/storefront/store` | Listing pages: pagination, sorting, collection/category/search templates |
44
- | `@cartbase/storefront/order` | Order confirmation surfaces |
45
- | `@cartbase/storefront/tracking` | Consent banner + consent-gated Meta Pixel / GA4 / analytics |
46
- | `@cartbase/storefront/theme` | The design system: token names plus a filled default set of values (Tailwind 4, CSS-first) |
47
-
48
- ## Documentation
49
-
50
- The complete reference every endpoint with request/response shapes and
51
- working examples, plus a step-by-step build runbook — is written to be
52
- followed by a developer **or handed to a coding agent as-is**. It ships
53
- inside every `npm create cartbase` scaffold under `docs/`, and online at
54
- your store's docs site. Start with *Build a storefront — the runbook*.
55
-
56
- ## License
57
-
58
- MIT © Cartbase
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