snack-sdk

January 27, 2026 · View on GitHub

snack-sdk

snack-sdk

Index

Classes

Interfaces

Type aliases

Functions

Type aliases

SDKFeature

Ƭ SDKFeature: "MULTIPLE_FILES" | "PROJECT_DEPENDENCIES" | "TYPESCRIPT" | "UNIMODULE_IMPORTS" | "POSTMESSAGE_TRANSPORT" | "VERSIONED_SNACKAGER"

Feature that is supported by the SDK (e.g. "TYPESCRIPT").


SDKVersion

Ƭ SDKVersion: "37.0.0" | "38.0.0" | "39.0.0" | "40.0.0"

Version of the sdk to use (e.g. "37.0.0").


SnackAssetFile

Ƭ SnackAssetFile: { contents: string | File | Blob | FormData ; error?: Error ; type: "ASSET" }

An asset file that refers to externaly available content such as an image or font.

When resolved, the contents field is an URL to the uploaded asset. A File, Blob or FormData object may also be provided after which it is automatically uploaded and converted into an URL.

Type declaration:

NameType
contentsstring | File | Blob | FormData
error?Error
type"ASSET"

SnackCodeFile

Ƭ SnackCodeFile: { contents: string ; error?: Error ; type: "CODE" }

A non asset file that is included with the project. This can be either a code file (.js/.tsx) or a support file such as a markdown or json file.

Type declaration:

NameType
contentsstring
error?Error
type"CODE"

SnackConnectedClient

Ƭ SnackConnectedClient: { error?: SnackError ; id: string ; name: string ; platform: string ; previewTimestamp?: undefined | number ; previewURL?: undefined | string ; status: SnackConnectedClientStatus ; transport: string }

Client which connected to the Snack.

Clients are only able to connect when the Snack is online.

Type declaration:

NameType
error?SnackError
idstring
namestring
platformstring
previewTimestamp?undefined | number
previewURL?undefined | string
statusSnackConnectedClientStatus
transportstring

SnackConnectedClientStatus

Ƭ SnackConnectedClientStatus: "ok" | "error" | "reloading"


SnackConnectedClients

Ƭ SnackConnectedClients: { [key:string]: SnackConnectedClient; }

Collection of connected clients.


SnackDependencies

Ƭ SnackDependencies: { [name:string]: SnackDependency; }

Dictionary of dependency names and their (resolved) versions.


SnackDependency

Ƭ SnackDependency: { error?: Error ; handle?: undefined | string ; peerDependencies?: SnackDependencyVersions ; version: string ; wantedVersion?: undefined | string }

The version, resolved handle, peer-dependencies and optional error of a dependency.

Type declaration:

NameType
error?Error
handle?undefined | string
peerDependencies?SnackDependencyVersions
versionstring
wantedVersion?undefined | string

SnackDependencyVersions

Ƭ SnackDependencyVersions: { [name:string]: string; }

Dictionary of dependencies and their version.


SnackFile

Ƭ SnackFile: SnackCodeFile | SnackAssetFile

The content of a Snack code or asset file.


SnackFiles

Ƭ SnackFiles: { [path:string]: SnackFile; }

Dictionary of file-names and their content that make up the files of the Snack.


SnackListenerSubscription

Ƭ SnackListenerSubscription: () => any


SnackLogEvent

Ƭ SnackLogEvent: { connectedClient?: SnackConnectedClient ; error?: SnackError ; message: string ; type: "error" | "warn" | "log" | "info" }

Log data for when a connected client calls one of the console.[log,info,warn,error] to log information to the console.

Type declaration:

NameType
connectedClient?SnackConnectedClient
error?SnackError
messagestring
type"error" | "warn" | "log" | "info"

SnackLogListener

Ƭ SnackLogListener: (log: SnackLogEvent) => any


SnackMissingDependencies

Ƭ SnackMissingDependencies: { [name:string]: SnackMissingDependency; }

Dictionary of dependencies that are missing.


SnackMissingDependency

Ƭ SnackMissingDependency: { dependents: string[] ; wantedVersion?: undefined | string }

Wanted version of the dependency that is missing, including the dependents which have this dependency as a peer-dependency.

Type declaration:

NameType
dependentsstring[]
wantedVersion?undefined | string

SnackOptions

Ƭ SnackOptions: { accountSnackId?: undefined | string ; apiURL?: undefined | string ; channel?: undefined | string ; codeChangesDelay?: undefined | number ; createTransport?: undefined | (options: SnackTransportOptions) => SnackTransport ; dependencies?: SnackDependencies ; description?: undefined | string ; deviceId?: undefined | string ; disabled?: undefined | false | true ; files?: SnackFiles ; host?: undefined | string ; id?: undefined | string ; name?: undefined | string ; online?: undefined | false | true ; previewTimeout?: undefined | number ; reloadTimeout?: undefined | number ; sdkVersion?: SDKVersion ; snackagerURL?: undefined | string ; snackId?: undefined | string ; transports?: undefined | { [id:string]: SnackTransport; } ; user?: SnackUser ; verbose?: undefined | false | true ; webPlayerURL?: undefined | string ; webPreviewRef?: SnackWindowRef }

Type declaration:

NameType
accountSnackId?undefined | string
apiURL?undefined | string
channel?undefined | string
codeChangesDelay?undefined | number
createTransport?undefined | (options: SnackTransportOptions) => SnackTransport
dependencies?SnackDependencies
description?undefined | string
deviceId?undefined | string
disabled?undefined | false | true
files?SnackFiles
host?undefined | string
id?undefined | string
name?undefined | string
online?undefined | false | true
previewTimeout?undefined | number
reloadTimeout?undefined | number
sdkVersion?SDKVersion
snackagerURL?undefined | string
snackId?undefined | string
transports?undefined | { [id:string]: SnackTransport; }
user?SnackUser
verbose?undefined | false | true
webPlayerURL?undefined | string
webPreviewRef?SnackWindowRef

SnackSaveOptions

Ƭ SnackSaveOptions: { ignoreUser?: undefined | false | true ; isDraft?: undefined | false | true }

Type declaration:

NameType
ignoreUser?undefined | false | true
isDraft?undefined | false | true

SnackSendBeaconRequest

Ƭ SnackSendBeaconRequest: { data: any ; url: string }

Request data to be used with the sendBeacon API.

Type declaration:

NameType
dataany
urlstring

SnackState

Ƭ SnackState: { accountSnackId: undefined |string ; channel: string ; connectedClients: SnackConnectedClients ; dependencies: SnackDependencies ; description: string ; deviceId?: undefined | string ; disabled: boolean ; files: SnackFiles ; id?: undefined | string ; missingDependencies: SnackMissingDependencies ; name: string ; online: boolean ; onlineName?: undefined | string ; saveURL?: undefined | string ; savedSDKVersion?: undefined | string ; sdkVersion: SDKVersion ; sendBeaconCloseRequest?: SnackSendBeaconRequest ; snackId: undefined |string ; unsaved: boolean ; url: string ; user?: SnackUser ; wantedDependencyVersions?: SnackDependencyVersions ; webPreviewURL?: undefined | string }

Type declaration:

NameTypeDescription
accountSnackIdundefined | stringId of the saved Snack if it belongs to an account.
channelstringCommunication channel ("snackpub") through which live updates are transferred. The communication channel is only used when the Snack is "online".
connectedClientsSnackConnectedClientsClients that are currently connected.
dependenciesSnackDependenciesPackages that can be used in the code files. Packages that are pre-loaded by the sdk may be ommited, but it is recommended to add them anyway.
descriptionstringAdditional description of the Snack. The description is used when saving the Snack and may also be used for searching purposes.
deviceId?undefined | stringDevice-id of the Expo client. When set causes the Snack to be visible in the "Recently in Development" section of the Expo client with that device-id. The device-id is only used when the Snack is "online".
disabledbooleanDisabled state. When the Snack is disabled it will not resolve any dependencies or upload any asset files. It also disables the ability to go online.
filesSnackFilesFiles that make up the content (code & assets) of the Snack. There should always be a file called "App.js" or "App.tsx" as the main entry point.
id?undefined | stringFull name of the saved Snack.
missingDependenciesSnackMissingDependenciesCollection of dependencies that are missing but are required by one or more of the dependencies.
namestringOptional name. The name is used when saving or downloading the Snack; and is used for the onlineName property.
onlinebooleanWhen online is true, Expo clients can connect to the Snack and receive live updates when code or dependencies are changed. It also makes the Snack visible in the "Recently in Development" section of the Expo client.
onlineName?undefined | stringName of the Snack as shown in the "Recently in Development" section in the Expo client. The online-name will be empty when the Snack is not "online".
saveURL?undefined | stringURL of the saved Snack. The URL is empty when no save "id" is available.
savedSDKVersion?undefined | stringLast saved (non-draft) Expo SDK version.
sdkVersionSDKVersionExpo SDK version.
sendBeaconCloseRequest?SnackSendBeaconRequestA close request that should be send using the browser sendBeacon API whenever the browser session is unloaded. This gives the Snack a last opportunity to gracefully close its connections so that the "Recently in Development" section in the Expo client no longer shows the Snack.
snackIdundefined | stringId of this version of the saved Snack.
unsavedbooleanUnsaved status of the Snack. Becomes true when the Snack code is changed and false whenever the Snack is saved.
urlstringUnique experience url which can be used to open the Expo client and connect to the Snack (e.g. "exp://exp.host/@snack/sdk.38.0.0-78173941").
user?SnackUser
wantedDependencyVersions?SnackDependencyVersionsCollection of packages and versions that are compatible with the selected SDK version. This is similar to using expo install, which ensures the latest compatible version is installed.
webPreviewURL?undefined | stringURL to use to when loading the web-preview in an iframe. Web-preview is supported from SDK 40 and higher. To enable it, set the webPreviewRef to the contentWindow of the iframe.

SnackStateListener

Ƭ SnackStateListener: (state: SnackState, prevState: SnackState) => any


SnackUser

Ƭ SnackUser: { sessionSecret?: undefined | string }

User that is used for communicating with the Expo servers.

Type declaration:

NameType
sessionSecret?undefined | string

SnackWindowRef

Ƭ SnackWindowRef: { current: Window | null }

Type declaration:

NameType
currentWindow | null

Functions

getPreloadedModules

getPreloadedModules(sdkVersion: SDKVersion, coreModulesOnly?: undefined | false | true): object

Returns the list of pre-loaded modules for the given SDK version.

Parameters:

NameType
sdkVersionSDKVersion
coreModulesOnly?undefined | false | true

Returns: object


getSupportedSDKVersions

getSupportedSDKVersions(): SDKVersion[]

Returns the list of supported SDK versions.

Returns: SDKVersion[]


isFeatureSupported

isFeatureSupported(feature: SDKFeature, sdkVersion: string): boolean

Checks whether a feature is supported by the given SDK version.

Parameters:

NameType
featureSDKFeature
sdkVersionstring

Returns: boolean


isModulePreloaded

isModulePreloaded(name: string, sdkVersion: SDKVersion, coreModulesOnly?: undefined | false | true): boolean

Checks whether a specific module/dependency is preloaded for the given SDK version.

Parameters:

NameType
namestring
sdkVersionSDKVersion
coreModulesOnly?undefined | false | true

Returns: boolean


isValidSemver

isValidSemver(version: string): boolean

Verifies whether a string is a valid semver.

Parameters:

NameType
versionstring

Returns: boolean


standardizeDependencies

standardizeDependencies(dependencies: any): SnackDependencies

Converts older dependency formats into the SnackDependencies type.

Parameters:

NameType
dependenciesany

Returns: SnackDependencies


validateSDKVersion

validateSDKVersion(sdkVersion: SDKVersion): SDKVersion

Parameters:

NameType
sdkVersionSDKVersion

Returns: SDKVersion