fetchContent().
Flutter: Single player and widget components are coming soon for the Flutter SDK. For now, use the full-screen feed via
ShortKitFeed.Fetching content
Before displaying videos, fetchContentItem objects from the ShortKit API:
- iOS (Swift)
- Android
- React Native
- Web
fetchContent(limit:filter:) returns an array of resolved ContentItem objects with streaming URLs, metadata, and captions. limit defaults to 10. Pass a FeedFilter to restrict results by tags, section, author, content type, or custom metadata. For full model definitions see the Content Types guide.
Single player
PlayerConfig
Embedding a player
- iOS (UIKit)
- iOS (SwiftUI)
- Android
- React Native
- Web
ViewController.swift
Activate and deactivate
The player does not manage its own visibility lifecycle. Callactivate() when the player is on screen and deactivate() when it leaves. This gives you full control over playback in scroll views, tab bars, and navigation stacks.
On React Native, use the
active prop instead of method calls. It defaults to the value of config.autoplay (which is true by default). Set it to false to pause and true to resume.
Widget
The widget displays a horizontal carousel or vertical grid of video cards with muted autoplay. Tapping a card opens the feed by default.WidgetConfig
Layout
WidgetConfig.layout controls whether the widget renders as a horizontal carousel or a vertical grid.
Grid parameters:
Two helper methods on
WidgetConfig make it easier to size the container when using a non-scrollable embedded grid:
- iOS (Swift)
- Android
- React Native
gridCellHeight returns nil for carousel layouts. preferredGridHeight returns nil for carousel layouts and for scrollable grid layouts (where total height is unbounded).Playback mode
WidgetConfig.playbackMode controls how the widget activates preview playback across its cells.
The
startSide parameter on gridAlternating controls which column plays in the first row:
- iOS (Swift)
- Android
- React Native
GridSide values: .left (default), .right.WidgetInput
WidgetInput describes a video by its playback ID. Pass an array of these to configure(with:) or appendItems(_:).
- iOS (Swift)
- Android
- React Native
Because
ContentItem.playbackId is optional, use compactMap when converting from fetchContent() results:Embedding a widget
- iOS (UIKit)
- Android
- React Native
- Web
ViewController.swift
Widget properties and callbacks
These properties are set on the widget component after initialization.- iOS (Swift)
- Android
- React Native
Set these directly on your
ShortKitWidgetViewController instance:setFeedItems(_ inputs: [FeedInput]) supplies an optional seed list of items for the full-screen feed that opens when a card is tapped. The widget’s own cards are always prepended so the tapped clip is the opening item; the seed items follow. FeedInput accepts the same inputs as the full-screen feed — see Embedding a Feed for details.Embedding a grid
UseWidgetLayout.grid to replace the carousel with a vertical grid. The example below embeds a scrollable standalone grid that fills its assigned frame:
- iOS (UIKit)
- Android
- React Native
ViewController.swift
Embedded (non-scrollable) grid
When the grid sits inside a host-managed scroll view alongside other content — for example, a home screen with a carousel above and a grid below — setscrollable: false. The grid expands to fit all of its content and lets the parent scroll view handle scrolling.
Three additional steps are required:
- Resize the container as items load. Subscribe to
onContentHeightChangeand update your height constraint whenever the grid’s content height changes. - Forward scroll events. Call
parentScrollViewDidScroll(_:)from the parent scroll view delegate so the widget can correctly score which grid cells are visible. - Append items for pagination. Call
appendItems(_:)to load additional items without a full reload.
- iOS (UIKit)
- Android
- React Native
ViewController.swift
preferredGridHeight(forContainerWidth:itemCount:):
Appending items
CallappendItems(_:) to add more items to the grid without a full reload — for example, when the user scrolls near the bottom:
appendItems is a no-op on an empty input array. It works on both scrollable and non-scrollable grid layouts, inserting items incrementally without a full reload. On carousel layouts it triggers a full reload instead.
Auto-rotation
Auto-rotation applies to carousel layout only (
WidgetLayout.carousel). Grid layouts use the playbackMode setting to control preview activation instead.autoplay is true (the default), the carousel widget automatically advances through cards. How advancement is triggered differs by platform:
- iOS — advancement is driven by the preview reaching its end (
singleVisibleRotatingmode). Each card plays until its preview clip finishes, then the carousel moves to the next card.rotationIntervalhas no effect on iOS. - Android and React Native — advancement is timer-based: the carousel advances to the next card after
rotationIntervalelapses, regardless of playback position.
Click actions
BothPlayerConfig.clickAction and WidgetConfig.clickAction accept the same values: