Never use VITE_ or REACT_APP_ for secret keys
Browser bundlers inline prefixed env vars into public JS. Only put public store slugs in frontend env config.
Framework Integration · React
Build custom product cards, filters, and checkout flows in React without maintaining your own backend server or risking leaked admin credentials.
Client-side React SPAs should call unauthenticated /public/stores/{slug} endpoints for catalogs and guest cart sessions, or mount <div data-shoprivet="...">, while reserving merchant /v1 API keys for a separate backend server.
Practical implementation
Load /public/stores/:slug/products and /payment-methods inside React hooks or TanStack Query.
Create a guest cart session on demand, store the returned bearer credential in browser storage, and sync items with POST/PATCH/DELETE.
Pass idempotencyKey at checkout and call POST /public/stores/:slug/orders/:orderNumber/confirm upon gateway return.
React catalog hook example
useEffect(() => {
fetch("https://api.shoprivet.io/public/stores/downtown-shop/products")
.then((r) => r.json())
.then((data) => setProducts(data.products));
}, []);
Requirements, pricing & limits
Browser bundlers inline prefixed env vars into public JS. Only put public store slugs in frontend env config.
You can also embed widget.js inside a React wrapper ref if you do not want to build custom cart UI yet.
Pure client-rendered React relies on JavaScript execution for product HTML; choose Next.js or Astro SSR if organic product page indexing is critical.
Check HTTP 401/410 on expired guest carts to automatically create a fresh cart token.
Direct answers
Related documentation & solutions
Start free at $0/month
Create a store in minutes, embed a catalog on your existing site, or call our public Storefront and /v1 APIs.
Create your free store