Documentation Index
Fetch the complete documentation index at: https://docs.neynar.com/llms.txt
Use this file to discover all available pages before exploring further.
Open the cast composer with a suggested cast. The user will be able to modify
the cast before posting it.
An app prompts the user to cast and includes an embed.
Usage
import { sdk } from '@farcaster/miniapp-sdk'
const text = "I just learned how to compose a cast";
const embeds = ["https://miniapps.farcaster.xyz/docs/sdk/actions/compose-cast"] as [string];
await sdk.actions.composeCast({
text,
embeds,
})
Parameters
text (optional)
Suggested text for the body of the cast.
Mentions can be included using the human-writeable form (e.g. @farcaster).
embeds (optional)
- Type:
[] | [string] | [string, string]
Suggested embeds. Max two.
parent (optional)
- Type:
{ type: 'cast'; hash: string }
Suggested parent of the cast.
close (optional)
Whether the app should be closed when this action is called. If true the app
will be closed and the action will resolve with no result.
channelKey (optional)
Whether the cast should be posted to a channel.
Return Value
The cast posted by the user, or undefined if set to close.
Note: The cast property in the result can be null if the user decides not to create the cast.
import { sdk } from "@farcaster/miniapp-sdk";
const result = await sdk.actions.composeCast({
text: "I just learned how to compose a cast",
embeds: ["https://miniapps.farcaster.xyz/docs/sdk/actions/compose-cast"],
channelKey: "farcaster" // optional channel
})
// result.cast can be null if user cancels
if (result?.cast) {
console.log(result.cast.hash)
console.log(result.cast.channelKey) // includes channel if posted to one
}