Function: CastButton()
function CastButton(__namedParameters: CastButtonProps): Element | null;
Defined in: packages/cast/src/cast-button.tsx:88
The platform's own Cast button.
This is the affordance Google's Cast Design Checklist expects, and using it is not cosmetic — each platform's button is wired to something an app-drawn button cannot reach:
- Android — a
MediaRouteButtonset up throughCastButtonFactory.setUpMediaRouteButton. On Android 13+ (with theMediaTransferReceiverthis package documents) a tap opens the system output switcher, the same sheet the volume rocker and the media notification open, so casting starts where users already look for it. Below 13 it opens the in-appMediaRouteChooserDialog. - iOS — a
GCKUICastButtonpresenting the framework's own device dialog. Discovery starts on the first tap by SDK design, which is what makes the iOS local-network permission prompt appear when the user asked for devices rather than at launch.
Either way the session that starts is an ordinary cast session: a
wireCastHandoff machine already wired up picks it up and runs the handoff,
exactly as if you had called handoff.castTo(id).
Renders nothing while cast is unavailable — before Cast.initialize()
has resolved, and forever on a device without Google Play services. That is
the checklist's own rule ("hide the cast icon when there is nothing to cast
to"), applied for you; in dev builds a one-time warning explains the empty
space if initialize() was never called.
Prefer this to a hand-drawn button. Cast.requestSession() and your own
device sheet built on getCastDevices() remain fully supported for apps
that want their own picker — they just do not get the system switcher.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | CastButtonProps |
Returns
Element | null
Example
<CastButton style={{ width: 32, height: 32 }} tintColor="#e7e7ea" />