Registry / communication / slack-edge

slack-edge

JSON →
library1.3.16jsnpmunverified

This library, currently at version 1.3.16, provides a framework for building Slack applications optimized for edge runtimes like Cloudflare Workers, Vercel Edge Functions, and Supabase Edge Functions. It also supports Deno, Bun, and Node.js. `slack-edge` emphasizes TypeScript support, offering enhanced type safety for Slack events and API interactions. It differentiates itself from Slack's Bolt framework by being specifically designed for edge environments, including out-of-the-box support for "lazy listeners" for asynchronous processing, similar to Bolt-Python. The project maintains a frequent release cadence, primarily focusing on bug fixes, dependency upgrades, and support for new Slack API event types. A key aspect is its minimal dependency footprint, relying primarily on `slack-web-api-client` for Slack API interactions. This design choice contributes to faster cold starts and lower resource consumption, making it ideal for serverless and edge computing architectures.

npm install slack-edge
INSTALL
IMPORT
SIG · SLACK-EDGE
S
slack-edge
communicationjavascriptv1.3.16
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SlackApp
import { SlackApp } from 'slack-edge';
const SlackApp = require('slack-edge');
The primary class for initializing and configuring your Slack application. While platform-specific adapters may re-export it, the core class is directly from 'slack-edge'.
SlackEnv
import type { SlackEnv } from 'slack-edge';
import { SlackEnv } from 'slack-edge';
A type definition for generic environment variables expected by the SlackApp. For platform-specific environments (e.g., Cloudflare Workers), use the types provided by the respective adapter package.
LazyListener
import type { LazyListener } from 'slack-edge';
import { LazyListener } from 'slack-edge';
A type definition for asynchronous event handlers that run outside the initial 3-second Slack response window.
CodedError
import type { CodedError } from 'slack-edge';
import { CodedError } from 'slack-edge';
Type for errors that include a specific error code, useful for handling API failures or internal framework errors.

Demonstrates a basic Slack app on Cloudflare Workers, handling a slash command. It uses `slack-edge`'s core `SlackApp` and integrates with `slack-cloudflare-workers` to manage the edge function request/response lifecycle, showcasing both synchronous acknowledgment and asynchronous lazy listeners.

import { SlackApp } from "slack-edge"; import { SlackEdgeAppEnv } from "slack-cloudflare-workers"; export default { async fetch( request: Request, env: SlackEdgeAppEnv, ctx: ExecutionContext ): Promise<Response> { // Initialize the SlackApp with environment variables provided by the adapter const app = new SlackApp({ env }) .command("/hello-cf-workers", async (req) => { // Synchronous handler, responsible for acknowledging the request within 3 seconds return ":wave: This app runs on Cloudflare Workers!"; // If no immediate response is needed, simply `async () => {}` works }, async ({ context: { respond } }) => { // Lazy listener, executed asynchronously for longer-running tasks // This can take more than 3 seconds without timing out the initial request await respond({ text: "This is an async reply. How are you doing?" }); } ); // Run the app using the Cloudflare Workers adapter's `run` method return await app.run(request, ctx); } }; // --- Local Development Environment Variables (e.g., in .dev.vars) --- // SLACK_SIGNING_SECRET=... // SLACK_BOT_TOKEN=xoxb-... // SLACK_LOGGING_LEVEL=DEBUG
Debug
Known issues
gotchaEdge functions have strict execution time limits (typically 3 seconds for initial Slack event responses). Any long-running operations in your synchronous handlers will cause timeouts.
fix
Offload all long-running tasks to 'lazy listeners' (the optional third argument in event handlers). These execute asynchronously, allowing the initial request to be acknowledged promptly.
affects: >=1.0.0
gotchaDirect usage of `slack-edge` for an edge runtime requires installing and configuring a platform-specific adapter package (e.g., `slack-cloudflare-workers`, `slack-vercel-edge`) to handle the request/response context.
fix
Install the appropriate adapter package for your chosen runtime environment and follow its documentation for proper integration, as shown in the quickstart for Cloudflare Workers.
affects: >=1.0.0
gotchaPrior to version 1.3.8, there was a bug where `oauth.start` might have been incorrectly used for OIDC endpoint customization, potentially leading to misconfiguration.
fix
Ensure `oidc.start` is used for OpenID Connect (OIDC) endpoint customization. Upgrade to version 1.3.8 or later to resolve this bug.
affects: <1.3.8
gotchaIncorrect or missing Slack environment variables (`SLACK_SIGNING_SECRET`, `SLACK_BOT_TOKEN`, etc.) are a very common cause of application startup failures or request validation errors, especially during local development.
fix
Always verify that all required Slack app environment variables are correctly set in your deployment environment and, for local development, in a `.dev.vars` file or equivalent.
affects: >=1.0.0
Errors
Common errors & fixes
HTTP 401: Invalid Signature
Signature verification failed
TypeError: app.run is not a function
Request timed out
ReferenceError: process is not defined
Upgrade
Version history
1.3.16latest on npm
Audit
Dependencies
@slack/web-api-clientrequiredCore client for interacting with the Slack API.
slack-cloudflare-workersoptionalProvides Cloudflare Workers specific features and environment setup; required for Cloudflare deployments.
slack-vercel-edgeoptionalProvides Vercel Edge Functions specific features and environment setup; required for Vercel deployments.
slack-denooptionalProvides Deno specific features and environment setup; required for Deno deployments.
slack-bunoptionalProvides Bun specific features and environment setup; required for Bun deployments.
slack-nodeoptionalProvides Node.js specific features and environment setup; required for Node.js deployments.
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
slack-edge — npm install slack-edge · libregistry