@farcaster/miniapp-sdk. These let your Mini App communicate with the host shell: close the frame, open external URLs, add the app to the user’s home, and trigger haptic feedback.
Import the SDK and call actions directly:
Checking supported capabilities
Before calling optional actions, query the host for what it supports:actions.ready
Required. Call this once on mount to signal the host that your Mini App has fully loaded. The host shows a loading screen untilready() is called.
ready() is never called, the host will display a timeout error to the user after 15 seconds.
actions.close
Closes the Mini App frame and returns the user to the Startale App home screen.actions.openUrl
Opens a URL in the device’s default browser. The host validates that the URL useshttp: or https:. Other protocols are silently blocked.
actions.addMiniApp
Adds the Mini App to the user’s home screen inside the Startale App. Returns{ result: {} } on success and fires a miniAppAdded SDK event you can listen to.
miniAppAdded event on the SDK if you want to react to the user saving your app:
Haptic feedback
Three haptic actions are available. Checksdk.context.features.haptics before calling them. On platforms that do not support haptics, the calls are no-ops.
actions.requestCameraAndMicrophoneAccess
Use this to enable the camera and microphone inside your Mini App. The flow has three steps, in order:- Check the feature flag. Read
context.features.cameraAndMicrophoneAccess. It istrueonly when the host runs your Mini App in a secure context (HTTPS) on a device that exposes media devices. If it isfalse, hide or disable your capture UI,getUserMediawould otherwise fail opaquely. - Call
sdk.actions.requestCameraAndMicrophoneAccess(). This signals the host that your Mini App is about to use the camera/mic. Alwaysawaitit before requesting a stream. - Call
navigator.mediaDevices.getUserMedia(...). This is the call that actually opens the stream and triggers the browser’s native permission prompt.
The browser permission prompt
When you callgetUserMedia, the browser shows its own native permission dialog asking the user to allow camera and microphone access. This dialog is rendered by the browser, not by your Mini App and not by the Startale App. You cannot style it, move it, or pre-fill the answer.
- If the user allows,
getUserMediaresolves with aMediaStream. - If the user denies (or has previously blocked the origin),
getUserMediarejects with aDOMExceptionwhosenameisNotAllowedError(orSecurityError). Handle this and show a recoverable state. - The browser remembers the choice per origin, so the prompt usually appears only on first use.
Releasing the stream
Stop every track when you’re done so the camera/mic indicator turns off, and clean up on unmount:mustard-demo-miniapp reference app (src/CameraSection.tsx).
Actions not supported in Startale App
The following actions exist in the Farcaster Mini App protocol but are not applicable inside the Startale App. Calling them will not throw, but they return immediately with no effect or anot_supported error.
For token transfers and swaps, use direct contract calls via
eth_sendTransaction or wallet_sendCalls with the appropriate calldata.