Devvit Reddit Developer Platform
repository·main·Indexed 42 days ago
https://github.com/reddit/devvitReddit's developer platform for building apps and moderation tools. Includes core packages like @devvit/web for web applications, @devvit/redis for state persistence, and @devvit/start for Vite-based builds. Features include menu actions, a background job scheduler, and integration with the Reddit API.
What's inside Devvit
- @devvit/cache is a promise cache helper designed to cache requests within the Reddit Developer Platform. It helps optimize performance by preventing redundant asynchronous operations through promise-based caching.
Overview of the Three Strikes moderation app
mainThe
three-strikesapp is a moderation tool designed to help moderators manage rule violators by issuing up to three strikes, each with escalating consequences. It serves as a reference implementation for several Devvit capabilities:- Moderator-only Menu Actions: Using
addMenuItemto create entrypoints that are restricted to community moderators. - State Persistence: Utilizing Redis to store and manage user-level strike data.
- Reddit API Integration: Leveraging the Reddit API to perform moderator actions and send private messages to users.
- Moderator-only Menu Actions: Using
Overview of the Remind Me app
mainTheremind-meapp is a menu action application that allows users to schedule reminders. When a user triggers the menu action, they can provide input via a form to schedule a reminder. At the specified time, the app uses the Devvit scheduler to trigger a job that sends a private message to the user containing a link to the specific post or comment they wanted to be reminded about.Overview of the comment-nuke app
mainThe
comment-nukeapp is a moderation tool designed to delete and lock entire comment trees, triggered by a single comment. It serves as a functional demonstration of two core Devvit capabilities:- Large-scale Reddit API operations: Performing bulk actions like deleting and locking multiple comments in a tree.
- Menu actions as entrypoints: Using Reddit's context menu (menu actions) to trigger app logic directly from the user interface.
Use @devvit/web for Devvit web applications
mainThe
@devvit/webpackage is a central dependency that provides core functionality for building web applications with Devvit. Instead of managing multiple individual packages, you can use@devvit/webto access all standard utilities. It is designed to work with any web framework of your choice.Module Structure
@devvit/web/server: Provides server-side utilities, such as Redis clients and access to the Reddit API.@devvit/web/client: Provides client-side utilities, including access to client-side context and effects.@devvit/web/shared: Provides utilities and types that are safe to use on both the client and the server.
Use the @devvit/realtime client
mainThe@devvit/realtimepackage provides a Realtime client designed for use within the Devvit framework. This allows developers to implement real-time capabilities in their Reddit applications. To use these features, you must first sign up for Reddit's Developer Platform.Use the @devvit/media client
mainThe@devvit/mediapackage provides a Media client designed for use within the Devvit framework. This client allows developers to interact with media assets on Reddit. To use these capabilities, you must first sign up for the Reddit Developer Platform.Use @devvit/redis for Redis client functionality
mainThe@devvit/redispackage provides a Redis client specifically designed for use within the Devvit framework. To use Redis services in your Devvit application, you must first sign up for Reddit's Developer Platform.Use the @devvit/notifications plugin
mainThe
@devvit/notificationspackage provides a Notifications client for the Devvit framework.⚠️ Warning: This plugin is currently experimental. The API is subject to change without notice and is not recommended for production use at this time.
Understand how @devvit/web-view-scripts works
mainThe
@devvit/web-view-scriptspackage is designed for web view apps that ship code via a CDN. Instead of being bundled with your application, the Devvit platform injects a script tag into your HTML files during the web view asset upload process. This script is always downloaded from the CDN at runtime.The injected script tag follows this format:
<script src="https://webview.devvit.net/scripts/devvit.v1.min.js?clientVersion=1.2.3"></script>Key Devvit features demonstrated in Remind Me
mainThe
remind-meapplication serves as a reference implementation for several core Devvit capabilities:- Menu Actions: Creating entrypoints for users to interact with the app directly from Reddit's interface.
- Devvit Scheduler: Scheduling background jobs to execute at a specific future timestamp.
- Forms: Collecting structured user input (e.g., reminder time/details) via UI forms.
- Reddit API Integration: Retrieving user metadata and sending private messages (PMs) to users.
- NPM Integration: Utilizing third-party NPM packages within the Devvit runtime environment.
Understand the relationship between @devvit/web and individual packages
mainThe
@devvit/webpackage acts as an umbrella dependency. It includes the functionality of the following individual packages:@devvit/client(Client-side utilities)@devvit/media(Media utilities)@devvit/realtime(Realtime communication)@devvit/reddit(Reddit API client)@devvit/redis(Redis client)@devvit/scheduler(Scheduler utilities)@devvit/server(Server-side utilities)@devvit/settings(Settings management)@devvit/shared(Shared utilities/types)
Important Exception:
@devvit/paymentsis not included in@devvit/web. If your application is approved to handle payments, you must install and use@devvit/paymentsseparately.