Readme · Guides · Reference · Contributing
Warning
The Optimization SDK Suite is pre-release (alpha). Breaking changes can be published at any time.
This is a reference implementation for the Optimization Web SDK and is part of the Contentful Optimization SDK Suite.
Use this implementation when you need the smallest browser example for the Web SDK without a framework layer. It demonstrates a static HTML integration, local mock API usage, Web SDK asset copying, and Playwright coverage for browser-side optimization and tracking behavior.
- Node.js >= 20.19.0 (24.13.0 recommended to match
.nvmrc) - pnpm 10.x
- Docker running locally for nginx-based serving
Run all steps from the monorepo root.
-
Install pnpm packages:
pnpm install
-
Build the local package tarballs consumed by implementations:
pnpm build:pkgs
-
Install this implementation so its local
@contentful/*dependencies resolve frompkgs/:pnpm implementation:run -- web-sdk implementation:install
-
Configure the environment in a
.envfile inimplementations/web-sdkbased on the.env.exampleincluded file. The file is pre-populated with values that are valid only against the mock server implementation. To test the implementation against a live server environment, see the mocks package for information on how to set up Contentful space with test data.
Run these commands from the monorepo root.
-
Start servers:
pnpm implementation:run -- web-sdk serve
-
Stop servers:
pnpm implementation:run -- web-sdk serve:stop
-
Run E2E:
pnpm test:e2e:web-sdk
The application can be accessed via Web browser at http://localhost:3000. See
implementations/web-sdk/package.json for lower-level local commands.
E2E tests are run using Playwright.
-
Install implementation dependencies, browser binaries, and system dependencies:
pnpm setup:e2e:web-sdk
-
Run the E2E test suite:
pnpm test:e2e:web-sdk
The tests can alternatively be run using Playwright's GUI:
pnpm implementation:run -- web-sdk test:e2e:ui
- @contentful/optimization-web - Web SDK package
- Web SDK React Adapter - Adapter-based React example built on the Web SDK
- Mocks package - Shared mock API server and fixtures