Optionalsettings: BrowserSettings
Optional overrides. Defaults to the resolved browser module.
The binding name this instance resolves.
The binding name as declared in wrangler.json.
Checks whether the binding is available on the given environment.
Use this to degrade gracefully when a binding is optional.
The Worker environment.
true when the binding is present.
Resolves the binding, failing fast when it is not configured.
The Worker environment.
The resolved binding.
MissingBindingError When the binding is absent from the environment.
Resolves the binding without throwing.
The Worker environment.
The resolved binding, or null when it is not configured.
Accessor for the Browser Rendering binding.
Remarks
Browser Rendering was the one binding in this package with no accessor, which meant the one Worker using it reached
env.BROWSERdirectly. An absent binding therefore arrived at the browser driver asundefinedand failed somewhere inside it, in that library's terms rather than in terms of the deployment that forgot to declare it. This class makes that aMissingBindingErrornamingBROWSER, like every other resource.Why there is no
BrowserServiceEvery other binding here has a capability service beside it. This one does not, and that is deliberate. Doing anything with a browser beyond holding the binding means driving it — launching, navigating, evaluating — which needs
@cloudflare/puppeteer, a real runtime dependency rather than a type. Taking it on would put a browser automation library in the dependency tree of every Worker that installs this package to get a KV accessor.The driving itself also has exactly one consumer today, and a capability with one implementation and one caller has not yet earned the interface. If a second appears, the shape to copy is
./middlewares: a separate subpath behind an optional peer, so a consumer that does not render pages never resolves the dependency.Fetcherrather than a browser-library type for the same reason — it is what the runtime hands over, and naming it costs no dependency.Example
Author
Bayu Dwiyan Satria
Version
1.0.0
Since
1.3.0