Skip to main content
Version: 0.10

@devvit/public-api

Table of contents

Namespaces

Enumerations

Classes

Type Aliases

Variables

Functions

Type Aliases

AllIconName

Ƭ AllIconName: typeof ALL_ICON_NAMES[number]


AppInstall

Ƭ AppInstall: "AppInstall"

The event name for when your app is installed


AppInstallDefinition

Ƭ AppInstallDefinition: Object

Type declaration

NameType
eventAppInstall
onEventTriggerOnEventHandler<protos.AppInstall>

AppUpgrade

Ƭ AppUpgrade: "AppUpgrade"

The event name for when your app is upgraded


AppUpgradeDefinition

Ƭ AppUpgradeDefinition: Object

Type declaration

NameType
eventAppUpgrade
onEventTriggerOnEventHandler<protos.AppUpgrade>

BaseContext

Ƭ BaseContext: Object

Type declaration

NameTypeDescription
appAccountIdstringThe ID of the current app's account
commentId?stringThe ID of the current comment
debugContextDebugInfoMore useful things, but probably not for the average developer
postId?stringThe ID of the current post
subredditIdstringThe ID of the current subreddit
userId?stringThe current user's ID if this event was triggered by a logged in user
toJSON() => Omit<BaseContext, "toJSON">Returns a JSON representation of the context

BaseField

Ƭ BaseField<ValueType>: Object

Type parameters

Name
ValueType

Type declaration

NameTypeDescription
defaultValue?ValueTypeThe default value of the field
disabled?booleanIf true the field will be disabled
helpText?stringAn optional help text that will be displayed below the field
labelstringThe label of the field. This will be displayed to the user
namestringThe name of the field. This will be used as the key in the values object when the form is submitted
required?booleanIf true the field will be required and the user will not be able to submit the form without filling it in
scope?SettingScopeTypeThis indicates whether the field (setting) is an app level or install level setting. App setting values can be used by any installation.

BlockElement

Ƭ BlockElement: Object

Type declaration

NameType
childrenJSX.Children[]
props{} | undefined
typeJSX.ComponentFunction | BlockComponent | CustomPostComponent | string | undefined

BooleanField

Ƭ BooleanField: Prettify<Omit<BaseField<boolean>, "required"> & FieldConfig_Boolean & { type: "boolean" }>

A boolean field displayed as a toggle


CancelJob

Ƭ CancelJob: (jobId: string) => Promise<void>

Cancel a scheduled job

Type declaration

▸ (jobId): Promise<void>

Parameters
NameTypeDescription
jobIdstringThe id of the job to cancel
Returns

Promise<void>


CommentCreate

Ƭ CommentCreate: "CommentCreate"

The event name for when a comment is created, after safety delay


CommentCreateDefinition

Ƭ CommentCreateDefinition: Object

Type declaration

NameType
eventCommentCreate
onEventTriggerOnEventHandler<protos.CommentCreate>

CommentDelete

Ƭ CommentDelete: "CommentDelete"

The event name for when a comment is deleted


CommentDeleteDefinition

Ƭ CommentDeleteDefinition: Object

Type declaration

NameType
eventCommentDelete
onEventTriggerOnEventHandler<protos.CommentDelete>

CommentReport

Ƭ CommentReport: "CommentReport"

The event name for when a comment is reported


CommentReportDefinition

Ƭ CommentReportDefinition: Object

Type declaration

NameType
eventCommentReport
onEventTriggerOnEventHandler<protos.CommentReport>

CommentSubmit

Ƭ CommentSubmit: "CommentSubmit"

The event name for when a comment is submitted


CommentSubmitDefinition

Ƭ CommentSubmitDefinition: Object

Type declaration

NameType
eventCommentSubmit
onEventTriggerOnEventHandler<protos.CommentSubmit>

CommentUpdate

Ƭ CommentUpdate: "CommentUpdate"

The event name for when a comment is updated


CommentUpdateDefinition

Ƭ CommentUpdateDefinition: Object

Type declaration

NameType
eventCommentUpdate
onEventTriggerOnEventHandler<protos.CommentUpdate>

Configuration

Ƭ Configuration: Object

Type declaration

NameTypeDescription
http?PluginSettings | booleanAllows your app to use the HTTP/Fetch API
kvStore?PluginSettings | booleanAllows your app to use the Key-Value Store
media?PluginSettings | booleanAllows media uploads from apps
modLog?PluginSettings | booleanAllows using ModLog API
realtime?PluginSettings | booleanAllows your app to use the Realtime Plugin
redditAPI?PluginSettings | booleanAllows your app to use the reddit API
redis?PluginSettings | booleanAllows your app to use the Redis Plugin

Context

Ƭ Context: ContextAPIClients & BaseContext

The current app context of the event or render


ContextAPIClients

Ƭ ContextAPIClients: Object

Type declaration

NameTypeDescription
assetsAssetsClientA client for resolving static assets to public URLs
cacheCacheHelperThe cache helper will let you cache JSON-able objects in your devvit apps for a limited amount of time. Under the covers, It's just Redis, so you do need to enable the redis feature. This provides a pattern for e.g. fetching remote calls without overwhelming someone's server. ts Devvit.configure({ redis: true, // Enable access to Redis }); /// ... let component = (context) => { let cached = context.cache(async () => { let rsp = await fetch("https://google.com") return rsp.body }, { key: "some-fetch", ttl: 10_000 // millis } doSomethingWith(cached); return <text>yay</text> }
kvStoreKVStoreA client for the Key Value Store
mediaMediaPluginA client for media API
modLogModLogClientA client for the ModLog API
realtimeRealtimeClientA client for Realtime API
redditRedditAPIClientA client for the Reddit API
redisRedisClientA client for the Redis API
schedulerSchedulerA client for the Scheduler API
settingsSettingsClientA client for the Settings API
uiUIClientA client for the User Interface API
useChannelUseChannelHookA hook hor managing a realtime pubsub channel between Block renders. This is only available within a Block Component.
useFormUseFormHookA hook for managing a form between Block renders. This is only available within a Block Component.
useIntervalUseIntervalHookA hook for managing a callback that runs on an interval between Block renders. This is only available within a Block Component.
useState(initialState: boolean | () => boolean | Promise<boolean>) => UseStateResult<boolean>(initialState: number | () => number | Promise<number>) => UseStateResult<number>(initialState: string | () => string | Promise<string>) => UseStateResult<string><S>(initialState: S | () => S | Promise<S>) => UseStateResult<S>A hook for managing a state between Block renders. This is only available within a Block Component. Returns a tuple containing the current state and a function to update it. ts const [counter, setCounter] = useState(0); setCounter(1); // counter = 1 setCounter((count) => count + 1) // counter = 2

ContextDebugInfo

Ƭ ContextDebugInfo: Object

Type declaration

NameType
metadataMetadata

CustomPostType

Ƭ CustomPostType: Object

Type declaration

NameTypeDescription
description?stringA description of the custom post type
height?RootHeightThe fixed height of the post, defaults to 'regular'
namestringThe name of the custom post type
renderCustomPostComponentA function component that renders the custom post

Data

Ƭ Data: Object

Index signature

▪ [key: string]: any


Dispatch

Ƭ Dispatch<A>: (value: A) => void

Type parameters

Name
A

Type declaration

▸ (value): void

Parameters
NameType
valueA
Returns

void


Form

Ƭ Form: Object

Type declaration

NameTypeDescription
acceptLabel?stringAn optional label for the submit button
cancelLabel?stringAn optional label for the cancel button
description?stringAn optional description for the form
fieldsFormField[]The fields that will be displayed in the form
title?stringAn optional title for the form

FormDefinition

Ƭ FormDefinition: Object

Type declaration

NameTypeDescription
formForm | FormFunctionA form or a function that returns a form
onSubmitFormOnSubmitEventHandlerA callback that will be invoked when the form is submitted

FormField

Ƭ FormField: StringField | ParagraphField | NumberField | BooleanField | SelectField | FormFieldGroup


FormFieldGroup

Ƭ FormFieldGroup: Object

A grouping of fields

Type declaration

NameTypeDescription
fieldsFormField[]The fields that will be displayed in the group
helpText?stringAn optional help text that will be displayed below the group
labelstringThe label of the group that will be displayed to the user
type"group"-

FormFunction

Ƭ FormFunction: (data: Data) => Form

A function that returns a form. You can use this to dynamically generate a form.

Example

const formKey = Devvit.createForm((data) => ({
fields: data.fields,
title: data.title,
}), callback);

...

ui.showForm(formKey, {
fields: [{ type: 'string', name: 'title', label: 'Title' }]
title: 'My dynamic form'
});

Type declaration

▸ (data): Form

Parameters
NameType
dataData
Returns

Form


FormKey

Ƭ FormKey: `form.${number}` | `form.hook.${string}.${number}`

A unique key generated by Devvit.createForm or the useForm hook.


FormOnSubmitEvent

Ƭ FormOnSubmitEvent: Object

Type declaration

NameTypeDescription
valuesFormValuesThe form values that were submitted

FormOnSubmitEventHandler

Ƭ FormOnSubmitEventHandler: (event: FormOnSubmitEvent, context: Context) => void | Promise<void>

Type declaration

▸ (event, context): void | Promise<void>

Parameters
NameType
eventFormOnSubmitEvent
contextContext
Returns

void | Promise<void>


FormValues

Ƭ FormValues: Data


IconName

Ƭ IconName: `${AllIconName}` | `${AllIconName}-outline` | `${AllIconName}-fill`


JSONArray

Ƭ JSONArray: JSONValue[]


JSONObject

Ƭ JSONObject: Object

Index signature

▪ [key: string]: JSONValue


JSONPrimitive

Ƭ JSONPrimitive: boolean | null | number | string


JSONValue

Ƭ JSONValue: JSONPrimitive | JSONArray | JSONObject

Any JSON type. Ie, a string, number, boolean, null, an array of these JSON types, or an object with JSON type values, recursively.

This type is often used to type-check attempts to serialize and deserialize classes, functions, and other JavaScript-only types that cannot be represented losslessly in plain JSON.

See


KVStore

Ƭ KVStore: Object

Type declaration

NameType
delete(key: string) => Promise<void>
get<T>(key: string) => Promise<undefined | T>
list() => Promise<string[]>
put(key: string, value: JSONValue) => Promise<void>

MediaAsset

Ƭ MediaAsset: Object

Type declaration

NameType
mediaIdstring
mediaUrlstring

MediaPlugin

Ƭ MediaPlugin: Object

Type declaration

NameType
upload(opts: UploadMediaOptions) => Promise<MediaAsset>

MenuItem

Ƭ MenuItem: Object

Type declaration

NameTypeDescription
description?stringAn optional description for the menu item
forUserType?MenuItemUserType | MenuItemUserType[]The user type(s) that the menu item should be displayed for
labelstringThe label of the menu item
locationMenuItemLocation | MenuItemLocation[]The location(s) where the menu item should be displayed
postFilter?MenuItemPostFilterThe filter that applies to post menu items. Has no effect on non-post actions
onPress(event: MenuItemOnPressEvent, context: Context) => void | Promise<void>A function that is called when the menu item is pressed

MenuItemLocation

Ƭ MenuItemLocation: "subreddit" | "post" | "comment"


MenuItemPostFilter

Ƭ MenuItemPostFilter: "currentApp"


MenuItemOnPressEvent

Ƭ MenuItemOnPressEvent: Object

Type declaration

NameTypeDescription
locationMenuItemLocationThe location where the menu item was pressed
targetIdstringThe ID of subreddit, post, or comment that the menu item was pressed; includes Thing ID prefix: - t1* - comment - t5* - subreddit - t3_ - post

MenuItemUserType

Ƭ MenuItemUserType: "loggedOut" | "member" | "moderator"


ModActionDefinition

Ƭ ModActionDefinition: Object

Type declaration

NameType
eventModActionTrigger
onEventTriggerOnEventHandler<protos.ModAction>

ModActionTrigger

Ƭ ModActionTrigger: "ModAction"

The event name for when a moderator action is recorded to a subreddit's modlog


ModMailDefinition

Ƭ ModMailDefinition: Object

Type declaration

NameType
eventModMailTrigger
onEventTriggerOnEventHandler<protos.ModMail>

ModMailTrigger

Ƭ ModMailTrigger: "ModMail"

The event name for when a mod mail is sent/received


MultiTriggerDefinition

Ƭ MultiTriggerDefinition<Event>: Object

Type parameters

NameType
Eventextends TriggerEvent

Type declaration

NameType
eventsreadonly Event[]
onEventTriggerOnEventHandler<TriggerEventType[Event]>

NumberField

Ƭ NumberField: Prettify<BaseField<number> & Omit<FieldConfig_Number, "min" | "max" | "step"> & { type: "number" }>

A number field


OnTriggerRequest

Ƭ OnTriggerRequest: protos.PostFlairUpdate | protos.PostSubmit | protos.PostCreate | protos.PostUpdate | protos.PostReport | protos.PostDelete | protos.CommentSubmit | protos.CommentCreate | protos.CommentUpdate | protos.CommentReport | protos.CommentDelete | protos.AppInstall | protos.AppUpgrade | protos.ModAction | protos.ModMail


OnValidateHandler

Ƭ OnValidateHandler<ValueType>: (event: SettingsFormFieldValidatorEvent<ValueType>, context: Context) => void | string | Promise<void | string>

Type parameters

Name
ValueType

Type declaration

▸ (event, context): void | string | Promise<void | string>

Parameters
NameType
eventSettingsFormFieldValidatorEvent<ValueType>
contextContext
Returns

void | string | Promise<void | string>


ParagraphField

Ƭ ParagraphField: Prettify<BaseField<string> & Omit<FieldConfig_Paragraph, "maxCharacters"> & { type: "paragraph" }>

A paragraph or textarea field


PluginSettings

Ƭ PluginSettings: Object

Type declaration

NameTypeDescription
enabledbooleanWhether the plugin is enabled

PostCreate

Ƭ PostCreate: "PostCreate"

The event name for when a post is created, after safety delay


PostCreateDefinition

Ƭ PostCreateDefinition: Object

Type declaration

NameType
eventPostCreate
onEventTriggerOnEventHandler<protos.PostCreate>

PostDelete

Ƭ PostDelete: "PostDelete"

The event name for when a post is deleted


PostDeleteDefinition

Ƭ PostDeleteDefinition: Object

Type declaration

NameType
eventPostDelete
onEventTriggerOnEventHandler<protos.PostDelete>

PostFlairUpdate

Ƭ PostFlairUpdate: "PostFlairUpdate"

The event name for when the flair of a post is updated


PostFlairUpdateDefinition

Ƭ PostFlairUpdateDefinition: Object

Type declaration

NameType
eventPostFlairUpdate
onEventTriggerOnEventHandler<protos.PostFlairUpdate>

PostReport

Ƭ PostReport: "PostReport"

The event name for when a post is reported


PostReportDefinition

Ƭ PostReportDefinition: Object

Type declaration

NameType
eventPostReport
onEventTriggerOnEventHandler<protos.PostReport>

PostSubmit

Ƭ PostSubmit: "PostSubmit"

The event name for when a post is submitted


PostSubmitDefinition

Ƭ PostSubmitDefinition: Object

Type declaration

NameType
eventPostSubmit
onEventTriggerOnEventHandler<protos.PostSubmit>

PostUpdate

Ƭ PostUpdate: "PostUpdate"

The event name for when a post is updated


PostUpdateDefinition

Ƭ PostUpdateDefinition: Object

Type declaration

NameType
eventPostUpdate
onEventTriggerOnEventHandler<protos.PostUpdate>

RedisClient

Ƭ RedisClient: Object

Type declaration

NameTypeDescription
globalOmit<RedisClient, "global">Allows read/write operations to global keys in Redis Global redis enables apps to persist and access state across subreddit installations
del(...keys: string[]) => Promise<void>Removes the specified keys. A key is ignored if it does not exist. https://redis.io/commands/del/ Arg keys
expire(key: string, seconds: number) => Promise<void>Set a timeout on key. https://redis.io/commands/expire/ Arg key Arg seconds
expireTime(key: string) => Promise<number>Returns the absolute Unix timestamp in seconds at which the given key will expire https://redis.io/commands/expiretime/ Arg key
get(key: string) => Promise<undefined | string>Get the value of key. If the key does not exist the special value nil is returned. https://redis.io/commands/get/ Arg key
getRange(key: string, start: number, end: number) => Promise<string>Returns the substring of the string value stored at key, determined by the offsets start and end (both are inclusive). https://redis.io/commands/getrange/ Arg key Arg start Arg end
hdel(key: string, fields: string[]) => Promise<number>Removes the specified fields from the hash stored at key. https://redis.io/commands/hdel/ Arg key Arg fields
hget(key: string, field: string) => Promise<undefined | string>Returns the value associated with field in the hash stored at key. https://redis.io/commands/hget Arg key Arg field
hgetall(key: string) => Promise<undefined | Record<string, string>>Returns a map of fields and their values stored in the hash https://redis.io/commands/hgetall Arg key
hincrby(key: string, field: string, value: number) => Promise<number>Increments the number stored at field in the hash stored at key by increment. https://redis.io/commands/hincrby/ Arg key Arg field Arg value
hkeys(key: string) => Promise<string[]>Returns all field names in the hash stored at key. Arg key
hscan(key: string, cursor: number, pattern?: string, count?: number) => Promise<HScanResponse>Iterates fields of Hash types and their associated values. Arg key Arg cursor Arg pattern Arg count
hset(key: string, fieldValues: { [field: string]: string; }) => Promise<number>Sets the specified fields to their respective values in the hash stored at key. https://redis.io/commands/hset Arg key Arg fieldValues
incrBy(key: string, value: number) => Promise<number>Increments the number stored at key by increment. https://redis.io/commands/incrby/ Arg key Arg value
mget(keys: string[]) => Promise<(null | string)[]>Returns the values of all specified keys. https://redis.io/commands/mget/ Arg keys
mset(keyValues: { [key: string]: string; }) => Promise<void>Sets the given keys to their respective values. https://redis.io/commands/mset/ Arg keyValues
set(key: string, value: string, options?: SetOptions) => Promise<string>Set key to hold the string value. If key already holds a value, it is overwritten https://redis.io/commands/set/ Arg key Arg value Arg options
setRange(key: string, offset: number, value: string) => Promise<number>Overwrites part of the string stored at key, starting at the specified offset, for the entire length of value. https://redis.io/commands/setrange/ Arg key Arg offset
strlen(key: string) => Promise<number>Returns the length of the string value stored at key. An error is returned when key holds a non-string value. https://redis.io/commands/strlen/ Arg key
type(key: string) => Promise<string>Returns the string representation of the type of the value stored at key https://redis.io/commands/type/ Arg key
watch(...keys: string[]) => Promise<TxClientLike>Marks the given keys to be watched for conditional execution of a transaction. https://redis.io/commands/watch/ Arg keys - given keys to be watched
zAdd(key: string, ...members: ZMember[]) => Promise<number>Adds all the specified members with the specified scores to the sorted set stored at key. https://redis.io/commands/zadd/ Arg key
zCard(key: string) => Promise<number>Returns the cardinality (number of elements) of the sorted set stored at key. https://redis.io/commands/zcard/ Arg key
zIncrBy(key: string, member: string, value: number) => Promise<number>Increments the score of member in the sorted set stored at key by value https://redis.io/commands/zincrby/ Arg key Arg member Arg value
zRange(key: string, start: string | number, stop: string | number, options?: ZRangeOptions) => Promise<{ member: string ; score: number }[]>Returns the specified range of elements in the sorted set stored at key. https://redis.io/commands/zrange/ Arg key Arg start Arg stop Arg options
zRank(key: string, member: string) => Promise<number>Returns the rank of member in the sorted set stored at key https://redis.io/commands/zrank/ Arg key Arg member
zRem(key: string, members: string[]) => Promise<number>Removes the specified members from the sorted set stored at key. https://redis.io/commands/zrem/ Arg key Arg members
zRemRangeByLex(key: string, min: string, max: string) => Promise<number>removes all elements in the sorted set stored at key between the lexicographical range specified by min and max https://redis.io/commands/zremrangebylex/ Arg key Arg min Arg max
zRemRangeByRank(key: string, start: number, stop: number) => Promise<number>Removes all elements in the sorted set stored at key with rank between start and stop. https://redis.io/commands/zremrangebyrank/ Arg key Arg start Arg stop
zRemRangeByScore(key: string, min: number, max: number) => Promise<number>Removes all elements in the sorted set stored at key with a score between min and max https://redis.io/commands/zremrangebyscore/ Arg key Arg min Arg max
zScore(key: string, member: string) => Promise<number>Returns the score of member in the sorted set at key. https://redis.io/commands/zscore/ Arg key Arg member

RunJob

Ƭ RunJob: (job: ScheduledJobOptions | ScheduledCronJobOptions) => Promise<string>

Schedule a new job to run at a specific time or on a cron schedule

Type declaration

▸ (job): Promise<string>

Parameters
NameTypeDescription
jobScheduledJobOptions | ScheduledCronJobOptionsThe job to schedule
Returns

Promise<string>


ScheduledCronJob

Ƭ ScheduledCronJob: Object

Type declaration

NameTypeDescription
cronstringThe cron string of when this job should run
dataData | undefinedAdditional data passed in by the scheduler client
idstringID of the scheduled job. Use this with scheduler.cancelJob to cancel the job.
namestringThe name of the scheduled job type

ScheduledCronJobOptions

Ƭ ScheduledCronJobOptions: Object

Type declaration

NameTypeDescription
cronstringThe cron string of when this job should run
data?DataAdditional data passed in by the scheduler client
namestringThe name of the scheduled job type

ScheduledJob

Ƭ ScheduledJob: Object

Type declaration

NameTypeDescription
dataData | undefinedAdditional data passed in by the scheduler client
idstringID of the scheduled job. Use this with scheduler.cancelJob to cancel the job.
namestringThe name of the scheduled job type
runAtDateThe Date of when this job should run

ScheduledJobEvent

Ƭ ScheduledJobEvent: Object

Type declaration

NameTypeDescription
data?DataAdditional data passed in by the scheduler client
namestringThe name of the scheduled job

ScheduledJobHandler

Ƭ ScheduledJobHandler: (event: ScheduledJobEvent, context: Context) => void | Promise<void>

Type declaration

▸ (event, context): void | Promise<void>

Parameters
NameType
eventScheduledJobEvent
contextContext
Returns

void | Promise<void>


ScheduledJobOptions

Ƭ ScheduledJobOptions: Object

Type declaration

NameTypeDescription
data?DataAdditional data passed in by the scheduler client
namestringThe name of the scheduled job type
runAtDateThe Date of when this job should run

ScheduledJobType

Ƭ ScheduledJobType: Object

Type declaration

NameTypeDescription
namestringThe name of the scheduled job type
onRunScheduledJobHandlerThe function that will be called when the job is scheduled to run

Scheduler

Ƭ Scheduler: Object

The Scheduler client lets you schedule new jobs or cancel existing jobs. You must have the scheduler enabled in Devvit.configure to use this client.

Type declaration

NameTypeDescription
cancelJobCancelJobCancel a scheduled job Param The id of the job to cancel
listJobs() => Promise<(ScheduledJob | ScheduledCronJob)[]>Gets the list of all scheduled jobs.
runJobRunJobSchedule a new job to run at a specific time or on a cron schedule Param The job to schedule

SelectField

Ƭ SelectField: Prettify<BaseField<string[]> & Omit<FieldConfig_Selection, "choices" | "renderAsList" | "minSelections" | "maxSelections"> & { options: FieldConfig_Selection_Item[] ; type: "select" }>

A dropdown field that allows users to pick from a list of options


SetOptions

Ƭ SetOptions: Object

Type declaration

NameType
expiration?Date
nx?boolean
xx?boolean

SetStateAction

Ƭ SetStateAction<S>: S | (prevState: S) => S

Type parameters

Name
S

SettingScopeType

Ƭ SettingScopeType: "installation" | "app"


SettingsClient

Ƭ SettingsClient: Object

The Settings API Client lets you retrieve the settings values for your app set by the installer. Use this in conjunction with Devvit.addSettings.

Type declaration

NameType
get<T>(name: string) => Promise<undefined | T>
getAll<T>() => Promise<T>

SettingsFormField

Ƭ SettingsFormField: ValidatedStringField | ValidatedParagraphField | ValidatedNumberField | ValidatedBooleanField | ValidatedSelectField | SettingsFormFieldGroup


SettingsFormFieldGroup

Ƭ SettingsFormFieldGroup: Prettify<Omit<FormFieldGroup, "fields"> & { fields: SettingsFormField[] }>


SettingsFormFieldValidatorEvent

Ƭ SettingsFormFieldValidatorEvent<ValueType>: Object

Type parameters

Name
ValueType

Type declaration

NameType
isEditingboolean
valueValueType | undefined

SettingsValues

Ƭ SettingsValues: Object

Index signature

▪ [key: string]: string | string[] | boolean | number | undefined


StateSetter

Ƭ StateSetter<S>: Dispatch<SetStateAction<S>>

Type parameters

Name
S

StringField

Ƭ StringField: Prettify<BaseField<string> & Omit<FieldConfig_String, "minLength" | "maxLength"> & { isSecret?: boolean ; type: "string" }>

A text field


Toast

Ƭ Toast: Object

Type declaration

NameTypeDescription
appearance?"neutral" | "success"The appearance of the toast
textstringThe message shown within the toast

TriggerContext

Ƭ TriggerContext: Omit<Context, "ui">


TriggerDefinition

Ƭ TriggerDefinition: PostSubmitDefinition | PostCreateDefinition | PostUpdateDefinition | PostFlairUpdateDefinition | PostReportDefinition | PostDeleteDefinition | CommentSubmitDefinition | CommentCreateDefinition | CommentUpdateDefinition | CommentReportDefinition | CommentDeleteDefinition | AppInstallDefinition | AppUpgradeDefinition | ModActionDefinition | ModMailDefinition


TriggerEvent

Ƭ TriggerEvent: PostSubmit | PostCreate | PostUpdate | PostReport | PostDelete | PostFlairUpdate | CommentSubmit | CommentCreate | CommentUpdate | CommentReport | CommentDelete | AppInstall | AppUpgrade | ModActionTrigger | ModMailTrigger


TriggerEventType

Ƭ TriggerEventType: Object

Maps a TriggerEvent to a Protobuf message and type.

Type declaration

NameType
AppInstall{ type: "AppInstall" } & protos.AppInstall
AppUpgrade{ type: "AppUpgrade" } & protos.AppUpgrade
CommentCreate{ type: "CommentCreate" } & protos.CommentCreate
CommentDelete{ type: "CommentDelete" } & protos.CommentDelete
CommentReport{ type: "CommentReport" } & protos.CommentReport
CommentSubmit{ type: "CommentSubmit" } & protos.CommentSubmit
CommentUpdate{ type: "CommentUpdate" } & protos.CommentUpdate
ModAction{ type: "ModAction" } & protos.ModAction
ModMail{ type: "ModMail" } & protos.ModMail
PostCreate{ type: "PostCreate" } & protos.PostCreate
PostDelete{ type: "PostDelete" } & protos.PostDelete
PostFlairUpdate{ type: "PostFlairUpdate" } & protos.PostFlairUpdate
PostReport{ type: "PostReport" } & protos.PostReport
PostSubmit{ type: "PostSubmit" } & protos.PostSubmit
PostUpdate{ type: "PostUpdate" } & protos.PostUpdate

TriggerOnEventHandler

Ƭ TriggerOnEventHandler<RequestType>: (event: RequestType, context: TriggerContext) => TriggerResult

Type parameters

Name
RequestType

Type declaration

▸ (event, context): TriggerResult

Parameters
NameType
eventRequestType
contextTriggerContext
Returns

TriggerResult


TxClientLike

Ƭ TxClientLike: Object

Type declaration

NameType
del(...keys: string[]) => Promise<TxClientLike>
discard() => Promise<void>
exec() => Promise<any[]>
expire(key: string, seconds: number) => Promise<TxClientLike>
expireTime(key: string) => Promise<TxClientLike>
get(key: string) => Promise<TxClientLike>
getRange(key: string, start: number, end: number) => Promise<TxClientLike>
hget(key: string, field: string) => Promise<TxClientLike>
hincrby(key: string, field: string, value: number) => Promise<TxClientLike>
hset(key: string, fieldValues: { [field: string]: string; }) => Promise<TxClientLike>
incrBy(key: string, value: number) => Promise<TxClientLike>
mget(keys: string[]) => Promise<TxClientLike>
mset(keyValues: { [key: string]: string; }) => Promise<TxClientLike>
multi() => Promise<void>
set(key: string, value: string, options?: SetOptions) => Promise<TxClientLike>
setRange(key: string, offset: number, value: string) => Promise<TxClientLike>
strlen(key: string) => Promise<TxClientLike>
type(key: string) => Promise<TxClientLike>
unwatch() => Promise<TxClientLike>
watch(...keys: string[]) => Promise<TxClientLike>
zAdd(key: string, ...members: ZMember[]) => Promise<TxClientLike>
zCard(key: string) => Promise<TxClientLike>
zRange(key: string, start: string | number, stop: string | number, options?: ZRangeOptions) => Promise<TxClientLike>
zRem(key: string, members: string[]) => Promise<TxClientLike>
zRemRangeByLex(key: string, min: string, max: string) => Promise<TxClientLike>
zRemRangeByRank(key: string, start: number, stop: number) => Promise<TxClientLike>
zRemRangeByScore(key: string, min: number, max: number) => Promise<TxClientLike>

UIClient

Ƭ UIClient: Object

The UI client lets your app interact with the Reddit frontend. This client will only be available for capabilities that have a frontend component, such as within the Custom Post component's event handlers, a Form's onSubmit handler, and Menu items.

Type declaration

NameType
navigateTo(url: string) => void(subreddit: Subreddit) => void(post: Post) => void(comment: Comment) => void(user: User) => void(urlOrThing: string | Subreddit | Post | User | Comment) => void
showForm(formKey: FormKey, data?: Data) => void
showToast(text: string) => void(toast: Toast) => void

UploadMediaOptions

Ƭ UploadMediaOptions: Object

Type declaration

NameType
typestring
urlstring

UseChannelHook

Ƭ UseChannelHook: (options: ChannelOptions) => UseChannelResult

Type declaration

▸ (options): UseChannelResult

Parameters
NameType
optionsChannelOptions
Returns

UseChannelResult


UseChannelResult

Ƭ UseChannelResult: Object

Type declaration

NameTypeDescription
send(data: Data) => Promise<void>Publish a message to the channel
statusChannelStatusCurrent subscription status
subscribe() => voidSubscribe to the channel
unsubscribe() => voidUnsubscribe from the channel

UseFormHook

Ƭ UseFormHook: (form: Form | FormFunction, onSubmit: (values: FormValues) => void | Promise<void>) => FormKey

A hook that returns a form key that can be used in the ui.showForm

Type declaration

▸ (form, onSubmit): FormKey

Parameters
NameType
formForm | FormFunction
onSubmit(values: FormValues) => void | Promise<void>
Returns

FormKey


UseIntervalHook

Ƭ UseIntervalHook: (callback: () => void | Promise<void>, delay: number) => UseIntervalResult

A hook that can used to run a callback on an interval between Block renders. Only one useInterval hook may be running at a time.

Type declaration

▸ (callback, delay): UseIntervalResult

Parameters
NameType
callback() => void | Promise<void>
delaynumber
Returns

UseIntervalResult


UseIntervalResult

Ƭ UseIntervalResult: Object

An object that contains functions to start and stop the interval created by the useInterval hook

Type declaration

NameTypeDescription
start() => voidStart the interval
stop() => voidStop the interval

UseStateHook

Ƭ UseStateHook: Context["useState"]


UseStateResult

Ƭ UseStateResult<S>: [S, StateSetter<S>]

A tuple containing the current state and a function to update it

Type parameters

Name
S

ValidatedBooleanField

Ƭ ValidatedBooleanField: Prettify<ValidatedFormField<BooleanField, boolean>>


ValidatedFormField

Ƭ ValidatedFormField<Field, ValueType>: Omit<Field, "required"> & { onValidate?: OnValidateHandler<ValueType> }

Type parameters

Name
Field
ValueType

ValidatedNumberField

Ƭ ValidatedNumberField: Prettify<ValidatedFormField<NumberField, number>>


ValidatedParagraphField

Ƭ ValidatedParagraphField: Prettify<ValidatedFormField<ParagraphField, string>>


ValidatedSelectField

Ƭ ValidatedSelectField: Prettify<ValidatedFormField<SelectField, string[]>>


ValidatedStringField

Ƭ ValidatedStringField: Prettify<ValidatedFormField<StringField, string>>


ZMember

Ƭ ZMember: Object

Type declaration

NameType
memberstring
scorenumber

ZRangeByScoreOptions

Ƭ ZRangeByScoreOptions: Object

Type declaration

NameType
limit?{ count: number ; offset: number }
limit.countnumber
limit.offsetnumber
withScores?boolean

ZRangeOptions

Ƭ ZRangeOptions: Object

Type declaration

NameType
by"score" | "lex" | "rank"
reverse?boolean

Variables

ALL_ICON_NAMES

Const ALL_ICON_NAMES: readonly ["activity", "add-emoji", "add", "add-media", "add-to-feed", "admin", "align-center", "align-left", "align-right", "all", "appearance", "approve", "archived", "aspect-ratio", "aspect-rectangle", "attach", "audio", "author", "avatar-style", "award", "back", "ban", "best", "binoculars", "block", "blockchain", "bold", "bot", "boost", "bounce", "browse", "browser", "cake", "calendar", "camera", "caret-down", "caret-left", "caret-right", "caret-up", "chat", "chat-group", "chat-new", "checkbox-dismiss", "checkbox", "checkmark", "chrome", "clear", "close", "closed-captioning", "code-block", "code-inline", "coins-color-old", "coins-color", "coins", "collapse-left", "collapse-right", "collection", "comment", "comments", "community", "contest", "controversial", "crop", "crosspost", "crowd-control", "custom-feed", "customize", "day", "delete", "discover", "dismiss-all", "distinguish", "down-arrow", "down", "download", "downvote", "downvotes", "drag", "drugs", "duplicate", "edit", "effect", "embed", "emoji", "end-live-chat", "error", "expand-left", "expand-right", "external", "feed-video", "filter", "format", "forward", "gif-post", "heart", "help", "hide", "history", "home", "hot", "ignore-reports", "image-post", "inbox", "info", "invite", "italic", "join", "joined", "jump-down", "jump-up", "karma", "keyboard", "kick", "language", "leave", "left", "link", "link-post", "list-bulleted", "list-numbered", "live-chat", "live", "load", "location", "lock", "logout", "loop", "mark-read", "mask", "media-gallery", "meme", "menu", "message", "mic", "mic-mute", "mod", "mod-mail", "mod-mode", "mod-mute", "mod-overflow", "mod-queue", "mod-unmute", "music", "new", "night", "notification", "notification-frequent", "notification-off", "nsfw", "nsfw-language", "nsfw-violence", "original", "overflow-caret", "overflow-horizontal", "overflow-vertical", "pause", "payment", "peace", "pending-posts", "phone", "pin", "planet", "play", "poll-post", "popular", "posts", "powerup-color-outline", "powerup-fill-color", "powerup", "predictions", "premium", "privacy", "profile", "qa", "qr-code", "quarantined", "quote", "r-slash", "radio-button", "raise-hand", "random", "ratings-everyone", "ratings-mature", "ratings-nsfw", "ratings-violence", "refresh", "remove", "reply", "report", "reverse", "right", "rising", "rotate", "rotate-image", "rpan", "rules", "safari", "save", "saved", "search", "self", "send", "settings", "share-android", "share", "share-ios", "show", "side-menu", "skipback10", "skipforward10", "sort-az", "sort", "sort-price", "sort-za", "spam", "spoiler", "sponsored", "star", "statistics", "status-live", "sticker", "strikethrough", "subtract", "superscript", "swap-camera", "swipe-back", "swipe-down", "swipe", "swipe-up", "table", "tag", "tap", "telescope", "text", "text-post", "text-size", "toggle", "tools", "top", "topic-activism", "topic-addictionsupport", "topic-advice", "topic-animals", "topic-anime", "topic-art", "topic-beauty", "topic-business", "topic-careers", "topic-cars", "topic-celebrity", "topic-craftsdiy", "topic-crypto", "topic-culture", "topic-diy", "topic-entertainment", "topic-ethics", "topic-family", "topic-fashion", "topic", "topic-fitness", "topic-food", "topic-funny", "topic-gender", "topic-health", "topic-help", "topic-history", "topic-hobbies", "topic-homegarden", "topic-internet", "topic-law", "topic-learning", "topic-lifestyle", "topic-marketplace", "topic-mature", "topic-mensfashion", "topic-menshealth", "topic-meta", "topic-military", "topic-movies", "topic-music", "topic-news", "topic-other", "topic-outdoors", "topic-pets", "topic-photography", "topic-places", "topic-podcasts", "topic-politics", "topic-programming", "topic-reading", "topic-religion", "topic-science", "topic-sexorientation", "topic-sports", "topic-style", "topic-tabletop", "topic-technology", "topic-television", "topic-traumasupport", "topic-travel", "topic-videogaming", "topic-womensfashion", "topic-womenshealth", "translate", "trim", "u-slash", "unban", "undo", "unheart", "unlock", "unmod", "unpin", "unverified", "up-arrow", "up", "upload", "upvote", "upvotes", "user", "user-note", "users", "vault", "verified", "video-camera", "video-feed", "video-live-1", "video-live-fill-1", "video-live", "video-post", "video-thread", "video-transcription", "view-card", "view-classic", "view-compact", "view-grid", "views", "volume", "volume-mute", "wallet", "warning", "wiki-ban", "wiki", "wiki-unban", "world"]

Functions

svg

svg(strings, ...args): `data:image/svg+xml;charset=UTF-8,${string}` | ""

A helper to allow SVG functionality within image tags.

Parameters

NameType
stringsTemplateStringsArray
...args(string | number)[]

Returns

`data:image/svg+xml;charset=UTF-8,${string}` | ""

Example

import { Devvit, svg } from '@devvit/public-api';
const App = () => {
const color = 'gold';
return (
<hstack>
<image
url={svg`<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg">
<circle fill="${color}" cx="5" cy="5" r="4" />
</svg>`}
imageHeight={100}
imageWidth={100}
/>
</hstack>
);
};
  • Table of contents
  • Type Aliases
    • AllIconName
    • AppInstall
    • AppInstallDefinition
    • AppUpgrade
    • AppUpgradeDefinition
    • BaseContext
    • BaseField
    • BlockElement
    • BooleanField
    • CancelJob
    • CommentCreate
    • CommentCreateDefinition
    • CommentDelete
    • CommentDeleteDefinition
    • CommentReport
    • CommentReportDefinition
    • CommentSubmit
    • CommentSubmitDefinition
    • CommentUpdate
    • CommentUpdateDefinition
    • Configuration
    • Context
    • ContextAPIClients
    • ContextDebugInfo
    • CustomPostType
    • Data
    • Dispatch
    • Form
    • FormDefinition
    • FormField
    • FormFieldGroup
    • FormFunction
    • FormKey
    • FormOnSubmitEvent
    • FormOnSubmitEventHandler
    • FormValues
    • IconName
    • JSONArray
    • JSONObject
    • JSONPrimitive
    • JSONValue
    • KVStore
    • MediaAsset
    • MediaPlugin
    • MenuItem
    • MenuItemLocation
    • MenuItemPostFilter
    • MenuItemOnPressEvent
    • MenuItemUserType
    • ModActionDefinition
    • ModActionTrigger
    • ModMailDefinition
    • ModMailTrigger
    • MultiTriggerDefinition
    • NumberField
    • OnTriggerRequest
    • OnValidateHandler
    • ParagraphField
    • PluginSettings
    • PostCreate
    • PostCreateDefinition
    • PostDelete
    • PostDeleteDefinition
    • PostFlairUpdate
    • PostFlairUpdateDefinition
    • PostReport
    • PostReportDefinition
    • PostSubmit
    • PostSubmitDefinition
    • PostUpdate
    • PostUpdateDefinition
    • RedisClient
    • RunJob
    • ScheduledCronJob
    • ScheduledCronJobOptions
    • ScheduledJob
    • ScheduledJobEvent
    • ScheduledJobHandler
    • ScheduledJobOptions
    • ScheduledJobType
    • Scheduler
    • SelectField
    • SetOptions
    • SetStateAction
    • SettingScopeType
    • SettingsClient
    • SettingsFormField
    • SettingsFormFieldGroup
    • SettingsFormFieldValidatorEvent
    • SettingsValues
    • StateSetter
    • StringField
    • Toast
    • TriggerContext
    • TriggerDefinition
    • TriggerEvent
    • TriggerEventType
    • TriggerOnEventHandler
    • TxClientLike
    • UIClient
    • UploadMediaOptions
    • UseChannelHook
    • UseChannelResult
    • UseFormHook
    • UseIntervalHook
    • UseIntervalResult
    • UseStateHook
    • UseStateResult
    • ValidatedBooleanField
    • ValidatedFormField
    • ValidatedNumberField
    • ValidatedParagraphField
    • ValidatedSelectField
    • ValidatedStringField
    • ZMember
    • ZRangeByScoreOptions
    • ZRangeOptions
  • Variables
    • ALL_ICON_NAMES
  • Functions
    • svg