Framework Integration · React

Add ecommerce to any React application.

Build custom product cards, filters, and checkout flows in React without maintaining your own backend server or risking leaked admin credentials.

How should React apps connect to Shoprivet safely?

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

Building with React & Shoprivet

  1. 1

    Fetch active catalog & payment methods

    Load /public/stores/:slug/products and /payment-methods inside React hooks or TanStack Query.

  2. 2

    Manage guest cart state via bearer tokens

    Create a guest cart session on demand, store the returned bearer credential in browser storage, and sync items with POST/PATCH/DELETE.

  3. 3

    Verify payment after redirect

    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

Security & SEO considerations for React apps

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.

Widget option for instant launch

You can also embed widget.js inside a React wrapper ref if you do not want to build custom cart UI yet.

SSR vs CSR SEO trade-off

Pure client-rendered React relies on JavaScript execution for product HTML; choose Next.js or Astro SSR if organic product page indexing is critical.

Clean error handling

Check HTTP 401/410 on expired guest carts to automatically create a fresh cart token.

Direct answers

Frequently asked questions

Can I build a full React ecommerce storefront without writing a backend?
Yes. All public catalog, guest cart, discount, checkout, and payment confirmation endpoints work safely from React browsers without an API key.
When do I need a backend server with React?
Only when automating merchant /v1 admin actions such as bulk product creation, inventory syncing, or reading all store orders.
Does Shoprivet provide a React guide?
Yes. See /docs/guides/react for React hooks, payment verification, and deployment tips.
Which payment gateways work in React storefronts?
Stripe, Paystack, Flutterwave, Razorpay, PayPal, and Cash on delivery.

Start free at $0/month

Launch with 0% Shoprivet platform fees.

Create a store in minutes, embed a catalog on your existing site, or call our public Storefront and /v1 APIs.

Create your free store