Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/capabilities/blocks/app_image_assets.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Adding Images
# Adding images

Add images to your interactive post.

Expand Down
6 changes: 3 additions & 3 deletions docs/capabilities/blocks/blocks_payments.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Adding Payments
# Adding payments

You can use the payments template to build your app or add payment functionality to an existing app.

Expand Down Expand Up @@ -42,7 +42,7 @@ Each product in the products field has the following attributes:
| `sku` | A product identifier that can be used to group orders or organize your products. Each sku must be unique for each product in your app. |
| `displayName` | The official name of the product that is displayed in purchase confirmation screens. The name must be fewer than 50 characters, including spaces. |
| `description` | A text string that describes the product and is displayed in purchase confirmation screens. The description must be fewer than 150 characters, including spaces. |
| `price` | An predefined integer that sets the product price in Reddit gold. See details below. |
| `price` | An predefined integer that sets the product price in Reddit Gold. See details below. |
| `image.icon` | **(optional)** The path to the icon that represents your product in your assets folder. |
| `metadata` | **(optional)** An optional object that contains additional attributes you want to use to group and filter products. Keys and values must be alphanumeric (a - Z, 0 - 9, and - ) and contain 30 characters or less. You can add up to 10 metadata keys. Metadata keys cannot start with "devvit-". |
| `accountingType` | Categories for how buyers consume your products. Possible values are: <ul><li>`INSTANT` for purchased items that are used immediately and disappear.</li><li>`DURABLE` for purchased items that are permanently applied to the account and can be used any number of times</li><li>`CONSUMABLE` for items that can be used at a later date but are removed once they are used.</li><li>`VALID_FOR_` values indicate a product can be used throughout a period of time after it is purchased.</li></ul> |
Expand Down Expand Up @@ -74,7 +74,7 @@ You’ll need to clearly identify paid products or services. Here are some best
- Use a short name, description, and image for each product.
- Don’t overwhelm users with too many items.
- Try to keep purchases in a consistent location or use a consistent visual pattern.
- Only use the gold icon to indicate purchases for Reddit gold.
- Only use the gold icon to indicate purchases for Reddit Gold.

### Product image

Expand Down
2 changes: 1 addition & 1 deletion docs/capabilities/client/forms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ A form lets your app ask users to input and submit data. Forms can be defined wi
</TabItem>
</Tabs>

## Menu Response Forms
## Menu response forms

For forms that open from a menu item, you can use menu responses. This is useful since you do not have access to the `@devvit/web/client` library from a menu item endpoint.

Expand Down
6 changes: 3 additions & 3 deletions docs/capabilities/client/menu-actions.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

# Menu Actions
# Menu actions

Add an item to the three dot menu for posts, comments, or subreddits. Menu actions can perform immediate client effects or trigger server processing followed by client effects.

![Subreddit menu actions](../../assets/capabilities/menu-actions/menu-actions-subreddit.png)

## Basic Menu Actions
## Basic menu actions

**For most menu actions, use direct client effects.** These provide immediate responses and are perfect for simple actions that don't require server processing.

Expand Down Expand Up @@ -121,7 +121,7 @@ context.ui.showForm(surveyForm);
</TabItem>
</Tabs>

## Supported Contexts
## Supported contexts

You can decide where the menu action shows up by specifying the location property.

Expand Down
2 changes: 1 addition & 1 deletion docs/capabilities/client/overview.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Overview
# Client Overview

Client-side effects enable your Devvit app to provide interactive feedback and navigation to users. These effects include showing toasts, displaying forms, navigating to different pages, and more.

Expand Down
2 changes: 1 addition & 1 deletion docs/capabilities/devvit-web/devvit_web_configuration.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Configure Your App
# Configure your app

The devvit.json file serves as your app's configuration file. Use it to specify entry points, configure features like [event triggers](../server/triggers) and [scheduled actions](../server/scheduler.mdx), and enable app functionality such as [image uploads](../server/media-uploads.mdx). This page covers all available devvit.json configuration options. A complete devvit.json example file is provided [here](#complete-example).

Expand Down
7 changes: 4 additions & 3 deletions docs/capabilities/devvit-web/devvit_web_overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ As with most experimental features, there are some caveats.

| Limitation | What it means |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Serverless endpoints | The node server will run just long enough to execute your endpoint function and return a response, which means you cant use packages that require long-running connections like streaming. |
| Serverless endpoints | The node server will run just long enough to execute your endpoint function and return a response, which means you can't use packages that require long-running connections like streaming. |
| Package limitations | Developers cannot use `fs` or external native packages. For now, we recommend using external services over the native dependencies, such as [StreamPot](https://streampot.io/) (instead of ffmpeg) and [OpenAI](https://platform.openai.com/docs/guides/embeddings) (instead of @xenova/transformers) . |
| Single request and single response handling only | Streaming or chunked responses and websockets are not supported. Long-polling is supported if it’s under the max request time. |
| No external requests from your client | You can’t have any external requests other than the app's webview domain. All backend responses are locked down to the webview domain via CSP. (Your backend can make external fetch requests though.) |
| Single request and single response handling only | Streaming or chunked responses and websockets are not supported. Long-polling is supported if it's under the max request time. |
| No external requests from your client | You can't have any external requests other than the app's webview domain. All backend responses are locked down to the webview domain via CSP. (Your backend can make external fetch requests though.) |
| localStorage clears on app updates | The iframe URL changes with each app version, so `localStorage` data is lost when you publish an update. Use [Redis](../server/redis.mdx) for data that needs to persist across app versions. |

Devvit Web still has the same technical requirements:

Expand Down
2 changes: 1 addition & 1 deletion docs/capabilities/server/cache-helper.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Cache Helper
# Cache helper

Cache helper lets you build a more performant app by reducing the number of server side calls for the same data. You can create a short-term cache that stores JSON objects in your Devvit app for a limited amount of time. This is valuable when you have many clients trying to get the same data, for example a stock ticker value or a sports score.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Overview
# View Modes, Launch Screens, and Entry Points

Devvit’s interactive framework gives you powerful ways to shape how users experience apps, from launch screen to expanded screen viewing. With view modes, HTML-based launch screens, and multiple entry points, you can design apps that feel native and respond to how users interact across the Reddit platform.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Setting up View Modes and Entry Points
# Setting up view modes and entry points

## View Modes
## View modes

Devvit apps support two view modes:

Expand All @@ -18,7 +18,7 @@ Devvit apps support two view modes:
- **Use case**: Full games, longer load times, detailed interfaces, or any content that needs more space or full gesture support
- **Trigger**: User-initiated only (button click, gesture, etc.)

## Multiple Entry Points
## Multiple entry points

Multiple entry points let the user start the game from different contexts or states. For example, you can have a button that launches into a leaderboard view and another for a specific game mode, each of these would be configured as an entry point for your app. Define multiple entry points in your `devvit.json`. If you use the [Devvit Vite plugin](../../../guides/tools/vite), it automatically infers the client build inputs from these entrypoints, so you don't need to maintain a custom Rollup `input` list.

Expand Down Expand Up @@ -78,7 +78,7 @@ your-app/

The `dir` property specifies where your built client files are located. With the Devvit Vite plugin, the `entry` values point at your source HTML files (for example `src/client/preview.html`), and the plugin outputs the matching files into `dist/client` during `vite build`.

### Creating Posts with Specific Entry Points
### Creating posts with specific entry points

Use the `entry` parameter when creating posts to specify which entry point from your `devvit.json` configuration to use. The entry value must match one of the keys defined in `post.entrypoints`.

Expand Down Expand Up @@ -118,7 +118,7 @@ async function createGamePost(context: any) {
- Each entry point can have its own HTML file and height setting.
- Invalid entry point names will cause an error.

### Switching Between View Modes
### Switching between view modes

You can transition from inline mode to expanded mode with a different entry point, like this:

Expand All @@ -135,7 +135,7 @@ const handleStartGame = async (event: React.MouseEvent) => {
};
```

## Inline Mode Requirements
## Inline mode requirements

All Devvit web view apps load in inline mode by default. Your app loads directly in the post unit without requiring users to click to expand.

Expand Down
33 changes: 33 additions & 0 deletions docs/capabilities/server/media-uploads.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,39 @@ On the server, you can pass the URL of any remotely hosted image (even if its no
</Tabs>


## Canvas screenshots

The Canvas API is fully supported by Devvit. You can use it to capture screenshots of your app's current state and upload them using the media API.

This is useful for letting users share their progress, achievements, or creations as image posts. Sharing screenshots is an effective way to build community engagement and increase visibility for your app.

```ts title="client/screenshot.ts"
// Capture the canvas as a data URL
const canvas = document.querySelector('canvas');
const dataUrl = canvas.toDataURL('image/png');

// Send to server endpoint for upload
const response = await fetch('/api/upload-screenshot', {
method: 'POST',
body: JSON.stringify({ image: dataUrl }),
});
```

```ts title="server/index.ts"
import { media } from '@devvit/media';

app.post('/api/upload-screenshot', async (c) => {
const { image } = await c.req.json();

const response = await media.upload({
url: image, // data URL from canvas
type: 'png',
});

return c.json({ url: response.mediaUrl });
});
```

## Limitations

- The formats supported are PNG, JPEG, WEBP, and GIF.
Expand Down
2 changes: 1 addition & 1 deletion docs/capabilities/server/overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Overview
# Server Overview

Devvit offers a wide variety of features that help you integrate your app with Reddit's APIs, scale your app free of charge using Reddit's backend, and more. The features in this section are executed on the server side. They can be imported in both [Devvit Web](../devvit-web/devvit_web_overview.mdx) and [Devvit Blocks](../blocks/overview.md) applications, as well as Mod Tools.

Expand Down
2 changes: 1 addition & 1 deletion docs/capabilities/server/post-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Post Data
# Post data

You can attach small amounts of data (2KB) to a post when creating it and update this data using the `postData` capability. This enables dynamic, stateful experiences available on posts without a server call. Post data is scoped to the post, not users.

Expand Down
17 changes: 16 additions & 1 deletion docs/capabilities/server/reddit-api.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Overview
# Reddit API Overview

The Reddit API allows you to read and write Reddit content such as posts / comments / upvotes, in order to integrate your app's behavior with the content of the community it's installed in.

:::note
Unlike traditional Reddit API usage, you don't need to create an app at [reddit.com/prefs/apps](https://www.reddit.com/prefs/apps) or manage API keys. Devvit handles authentication automatically when you enable the `reddit` permission in your app.
:::

## Private user data

Devvit apps cannot access certain private user data. This data is private to the logged-in user and is not exposed through the Devvit platform:

- **Subscribed subreddits** - The list of subreddits a user is subscribed to
- **Upvoted and downvoted content** - Posts and comments the user has voted on
- **Saved content** - Posts and comments the user has saved
- **Recently viewed posts** - The user's browsing history
- **Private profile information** - Any profile data that is not publicly visible
- **Follows and friends** - The list of users someone follows (on reddit.com) or has friended (on Old Reddit)

## The Reddit client

Here's how to obtain a reference to the Reddit client
Expand Down
42 changes: 13 additions & 29 deletions docs/capabilities/server/text_fallback.mdx
Original file line number Diff line number Diff line change
@@ -1,45 +1,29 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Text Fallback for old.reddit
# Text Fallback

Old.reddit does not render interactive posts. To remedy this, use textFallback to ensure that you can specify the text for the instances when Devvit cannot render your post. You can do this with a text string or in rich text.
Text fallback lets you specify alternative text content for your interactive post, enabling:

Setting a relevant text fallback is critical for SEO and growth of your app.
- **Old Reddit and third-party app support** - These platforms cannot render interactive posts
- **Google (SEO) and Reddit Answers indexing** - Critical for discoverability and growth
- **AutoModerator rule compatibility** - Allows mod rules to process your post content
- **Reddit safety checks and filters** - Enables content moderation systems to work properly
- **Custom post thumbnail** - Link to an image to generate a thumbnail

Text fallback uses Markdown formatting and allows for up to 40,000 characters.

## [Reddit API](./reddit-api.mdx)
The text fallback is only available when using the Reddit API to create a post. It is available for both [Devvit Web](../devvit-web/devvit_web_overview.mdx) and [Devvit Blocks](../blocks/overview.md) applications.
The code samples below assume that you already have a reference to the Reddit API client. Please see below how to obtain a refere
nce to the Reddit API client in both Devvit Web and Devvit Blocks.
The text fallback is only available when using the Reddit API to create a post.



<Tabs>
<TabItem value="web" label="Devvit Web">
```json title="devvit.json"
{
"permissions": {
"redditApi": true
"reddit": true
}
}
```

```ts title="server/index.ts"
import { reddit } from '@devvit/web/server';
```
</TabItem>
<TabItem value="blocks" label="Devvit Blocks / Mod Tools">
```ts
import { Devvit } from '@devvit/public-api';

Devvit.configure({
redditApi: true,
});

//Then, in any function that has a reference to Devvit.Context:
const reddit = context.reddit;
```
</TabItem>
</Tabs>

## Use a text string

```tsx
Expand Down
11 changes: 8 additions & 3 deletions docs/capabilities/server/userActions.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# User Actions
# User actions

User actions allow your app to submit posts, submit comments, and subscribe to the current subreddit on behalf of the logged in user. These actions occur on the logged in user's account instead of the app account. This enables stronger user engagement while ensuring user control and transparency.

Expand All @@ -14,6 +14,13 @@ By default, apps make posts or comments using their associated app account. With
- Create posts or comments on behalf of the user (from the post UI, a form, or a menu action)
- Subscribe the user to the current subreddit

### Unavailable actions

Some actions are not available to apps to prevent abuse and maintain platform integrity:

- **Voting** - Apps cannot upvote or downvote posts or comments, either as the app account or on behalf of the logged-in user
- **Following/friending users** - Apps cannot follow users (on reddit.com) or add friends (on Old Reddit), either as the app account or on behalf of the logged-in user

---

Requirements
Expand Down Expand Up @@ -86,8 +93,6 @@ Apps that use `submitPost()` with `runAs: 'USER'` require `userGeneratedContent`

## Example: Submit a post as the user

This example uses a form to prompt the user for input and then submits a post as the user.

<Tabs
variant="pill"
groupId="http-server-framework"
Expand Down
Loading