Devvit Reddit Developer Platform

repository·main·Indexed 42 days ago

https://github.com/reddit/devvit

Reddit'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.

Tokens
66.1K
Snippets
253
Records
337
Agent score
50%

What's inside Devvit

  1. Overview of the Three Strikes moderation app

    main

    The three-strikes app 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 addMenuItem to 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.
  2. Overview of the Remind Me app

    main
    The remind-me app 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.
  3. Overview of the comment-nuke app

    main

    The comment-nuke app 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:

    1. Large-scale Reddit API operations: Performing bulk actions like deleting and locking multiple comments in a tree.
    2. Menu actions as entrypoints: Using Reddit's context menu (menu actions) to trigger app logic directly from the user interface.
  4. Use @devvit/web for Devvit web applications

    main

    The @devvit/web package is a central dependency that provides core functionality for building web applications with Devvit. Instead of managing multiple individual packages, you can use @devvit/web to 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.
  5. Use the @devvit/realtime client

    main
    The @devvit/realtime package 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.
  6. Use the @devvit/media client

    main
    The @devvit/media package 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.
  7. Understand how @devvit/web-view-scripts works

    main

    The @devvit/web-view-scripts package 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>
  8. Key Devvit features demonstrated in Remind Me

    main

    The remind-me application 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.
  9. Understand the relationship between @devvit/web and individual packages

    main

    The @devvit/web package 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/payments is not included in @devvit/web. If your application is approved to handle payments, you must install and use @devvit/payments separately.