When your router opens another product, update the context. When it leaves a product page, pass null. Remove the integration when its host component unmounts.
Lifecycle
glasshouse.updateContext({ productId: 'lavender-5l' })
glasshouse.updateContext({ productId: null })
// When the host component unmounts:
glasshouse.destroy()
Use with a frontend framework
Keep GlassHouse in a component that remains mounted across product-page navigation. Use your framework’s browser lifecycle to mount it, pass route changes to updateContext, and call destroy on unmount. If a component unmounts while the asynchronous mount is still loading, destroy the returned instance when it resolves.
The package bundles its own UI runtime; your store can use React, Vue, Svelte or another framework.
Plain HTML without a bundler
Extract the package and self-host its complete dist directory at /glasshouse/. Keep its folders together so the interface can load its assets.
Open the launcher, ask about a product and follow its product link. Then create a planting layout. Add the cart adapter when you’re ready to let shoppers apply a design to their cart.