react-islands-runtime
v0.1.25
Published
SSR-first React islands runtime and server helpers
Readme
react-islands demo
An SSR-first React islands playground plus the react-islands-runtime package. The demos serve a small e-commerce experience:
- Home with search and cart islands
- Product detail pages with image, price, and add-to-cart form
- Products listing that returns the first 20 products
- Real commercetools-backed search/cart APIs (with graceful fallbacks)
Getting started
Prereqs: Node >= 22 and Yarn.
Demo apps (standalone)
Examples are self-contained. Run them from the examples workspace:
cd examples
yarn install
yarn dev:contentstack
# visits: http://localhost:3001Other demos:
yarn dev:commercetools # http://localhost:3000
yarn dev:agility # http://localhost:3002
yarn dev:contentstack-commercetools # http://localhost:3003Dev runs Vite (client) and the Express server with automatic port cleanup. For a production-like run, build the client assets and start a demo server:
yarn build:client
NODE_ENV=production node contentstack-demo/server/index.jsRuntime packaging
This repo publishes the conceptual runtime as separate entry points (no UI components):
react-islands-runtime/ssrreact-islands-runtime/islandsreact-islands-runtime/rsc
Install from npm:
npm install react-islands-runtimeKey routes
/home with search and mini-cart islands/productsfirst 20 products/products/:skuproduct detail with add-to-cart form/api/search,/api/search/suggestionsfor the typeahead/api/cartand/api/cart/itemsfor cart island and PDP form
Configuration
Environment variables (optional but recommended):
CART_CURRENCY(defaultUSD)DEFAULT_LOCALE(defaulten-US)USE_DEMO_DATA(set totrueto use demo data instead of commercetools)- commercetools creds
- Contentstack creds (contentstack demos only)
.env example
# Core
CART_CURRENCY=USD
DEFAULT_LOCALE=en-US
# Demo data
USE_DEMO_DATA=true
# Commercetools
CT_PROJECT_KEY=your-project-key
CT_CLIENT_ID=your-client-id
CT_CLIENT_SECRET=your-client-secret
CT_AUTH_URL=https://auth.europe-west1.gcp.commercetools.com
CT_API_URL=https://api.europe-west1.gcp.commercetools.com
# Contentstack (optional)
CONTENTSTACK_API_KEY=your-api-key
CONTENTSTACK_DELIVERY_TOKEN=your-delivery-token
CONTENTSTACK_ENVIRONMENT=prod
CONTENTSTACK_REGION=usThe demo server loads examples/.env and, when DEMO_TARGET is set, examples/.env.<demo> if present.
Project structure
examples/*/src/app/routesfile-based routes (layouts + pages)examples/*/src/app/islandsSSR + client entry pointssrc/clientislands runtime entrysrc/serverSSR runtime (router, renderer, manifest provider)examples/*/controllers/examples/*/modelscommerce and CMS adapters
Notes
- Server imports use ESM with
.jsextensions; the build emits todist/. - Islands manifest is generated during
yarn build:clientviareact-islands-gen-manifestusing the Vite manifest. - The add-to-cart form posts to
/api/cart/itemsand respects existing session cart.
