npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

netlify-plugin-discord-notifier

v1.4.0

Published

Netlify build plugin - Send build notifications to Discord

Readme

netlify-plugin-discord-notifier

A Netlify build plugin to notify build statuses with Discord Webhook.

Installation

Use npm, yarn or pnpm to add the plugin to the devPendencies in package.json.

npm install -D netlify-plugin-discord-notifier

Add the plugin to your netlify.toml configuration file:

# netlify.toml

[[plugins]]
package = "netlify-plugin-discord-notifier"

Webhook

In order to send notifications to the right place, you first need to create a Discord Webhook to the channel in which you want to receive the build notifications, by following Discord documentation.

Once you have your webhook url, go to Netlify admin panel and add it as an environment variable as DISCORD_WEBHOOK_URL.

That's all you need to make this plugin work!

Plugin configuration

This plugin can either be configured via the netlify.toml file or via a discord-notifier.config.js or discord-notifier.config.ts file (see here)

[!IMPORTANT] Note that discord-notifier.config.js and discord-notifier.config.ts will take precedence over any configuration done in netlify.toml

Bot

Add global bot configuration in your netlify.toml like so:

# netlify.toml

[[plugins]]
package = "netlify-plugin-discord-notifier"

    [plugins.inputs.bot]
    username = "My Bot"
Available attributes

| Key | Type | Default | |-----------|--------|----------------------------------------------------------| | username | String | Netlify | | avatarUrl | String | https://www.netlify.com/v3/static/favicon/icon-512.png |

Event bound configuration

Each build event has its own configuration key. To change its configuration, update your netlify.toml:

# netlify.toml

[[plugins]]
package = "netlify-plugin-discord-notifier"

    [plugins.inputs.preBuild]
    disabled = false
Supported event keys
type SupportedEventKeys = 
  | "success" 
  | "error" 
  | "preBuild" 
  | "build" 
  | "postBuild" 
  | "end" 
  | "preDev" 
  | "dev";
Available attributes

| Key | Type | Comment | |------------------|-----------|----------------------------------------------------------------------------------------------------------------| | disabled | Boolean | | | title | Template | See here on how to customise the title | | description | Template | See here on how to customise the description | | color | Hex color | Use Discord.js doc for color reference | | showBuildId | Boolean | | | showContext | Boolean | | | showBranch | Boolean | | | showCommit | Boolean | | | showDiff | Boolean | | | showLogs | Boolean | | | customWebhookKey | String | Use it for custom env variable key (e.g. defining different webhook per event type) | | templates | Templates | See here on how to customise templates | | formatter | Formatter | See here for custom formatter |

A default configuration is provided for each event (e.g. disabling notification for preDev and dev events) and available in config.ts.

Custom messages

If the default messages do not fulfill your need, you can customise them using the templates, title and description attributes.

Templating is handle by eta and allows you to inject variables in your messages.

The templates object is as follows:

| Key | Default | |------------------|-----------------------------------------------------------| | buildId | <%= it.env["BUILD_ID"] %> | | context | <%= it.env["CONTEXT"] %> | | branch | <%= it.env["BRANCH"] %> | | commit | [<%= it.env["COMMIT_REF"] %>](<%= it.meta.commitUrl %>) | | diff | <%= it.meta.diffUrl %> | | logs | <%= it.meta.logsUrl %> |

and supports the following values:

type TemplateParameters = {
  // https://docs.netlify.com/extend/develop-and-share/develop-build-plugins/#environment-variables
  env: Record<string, unknown>;
  // https://docs.netlify.com/extend/develop-and-share/develop-build-plugins/#inputs
  inputs: Record<string, unknown>;
  // https://docs.netlify.com/extend/develop-and-share/develop-build-plugins/#constants
  constants: Record<string, unknown>;
  // https://docs.netlify.com/extend/develop-and-share/develop-build-plugins/#netlifyconfig
  netlifyConfig: Record<string, unknown>;
  // https://docs.netlify.com/extend/develop-and-share/develop-build-plugins/#packagejson
  packageJson: Record<string, unknown>;
  
  // The complete configuration object produced after inputs
  config: Config;
  // The event bound configuration
  statusConfig: EventConfig;
  
  // Metadata
  meta: {
    // Application url to Netlify (https://app.netlify.com/sites/XXX)
    appUrl: string;
    // Current server time as string
    time: string;
    // URL of the commit associated with the build
    commitUrl: string;
    // URL for the deployed artifact (production or preview)
    deployUrl: string;
    // URL for the git diff between current and previous build
    diffUrl: string;
    // URL for the build logs
    logsUrl: string;
  };
}

Custom setup example

# netlify.toml

[[plugins]]
package = "netlify-plugin-discord-notifier"

    [plugins.inputs.postBuild]
    disabled = false
    title = 'Build passed flawlessly! 💯'
    description = '[<%= it.env["SITE_NAME"] %>](<%= it.meta.deployUrl  %>) has finished building at <%= it.meta.time %>. Ship it! 🚢'
    
    [plugins.inputs.preBuild]
    disabled = false
    title = 'A new build has been launched! 🚀'
    description = '[<%= it.env["SITE_NAME"] %>](<%= it.meta.deployUrl  %>) has started a new build at <%= it.meta.time %>. Let´s rock! 🤘🎸'
    showBranch = true

    [plugins.inputs.preBuild.templates]
    branch = '<%= it.env["BRANCH"] %> - <% if (it.env["PULL_REQUEST"] !== "false") { %> PR <% } else { %> Not a PR <% } %>'

Javascript / Typescript config file

The same configuration can be defined within a discord-notifier.config.js or discord-notifier.config.ts file.

// discord-notifier.config.ts
import type {DiscordNotifierConfig} from 'netlify-plugin-discord-notifier';

const config: DiscordNotifierConfig = {
  postBuild: {
    disabled: false,
    title: 'Build passed flawlessly! 💯',
    description: '[<%= it.env["SITE_NAME"] %>](<%= it.meta.deployUrl  %>) has finished building at <%= it.meta.time %>. Ship it! 🚢'
  },
  preBuild: {
    disabled: false,
    title: 'A new build has been launched! 🚀',
    description: '[<%= it.env["SITE_NAME"] %>](<%= it.meta.deployUrl  %>) has started a new build at <%= it.meta.time %>. Let´s rock! 🤘🎸',
    showBranch: true,
    templates: {
      branch: '<%= it.env["BRANCH"] %> - <% if (it.env["PULL_REQUEST"] !== "false") { %> PR <% } else { %> Not a PR <% } %>',
    }
  }
}

// Default export should contain the config object
export default config;

Fully custom webhook

If that's not enough, you can simply use a formatter function on each event configuration and return the object you want to send.

// discord-notifier.config.ts
import type {
  DiscordNotifierConfig,
  BuildEventParams,
  DiscordBody
} from 'netlify-plugin-discord-notifier';

const config: DiscordNotifierConfig = {
  // ...
  preBuild: {
    disabled: false,
    // ...
    // Formatter overrides all other parameters
    formatter: (params: BuildEventParams): DiscordBody => {
      return {
        username: 'My bot',
        embeds: [{
          title: 'Build is starting',
          description: `I just need to know **${process.env["SITE_NAME"]}** started building`,
        }],
      }
    }
  }
}

export default config;