jsx-slack is a JavaScript/TypeScript library designed to simplify the creation of Slack Block Kit JSON payloads using a JSX-like syntax. As of its current stable version 6.1.2, the library provides a declarative way to define rich Slack messages, modals, and other surfaces by composing components rather than manually crafting complex JSON objects. It supports a flexible development experience, offering a `jsxslack` tagged template literal for environments without a JSX transpiler, as well as full JSX support for projects leveraging Babel or TypeScript. The project maintains a regular release cadence with frequent patch and minor updates, and occasional major versions introducing breaking changes like Node.js engine updates or API behavior modifications. Its key differentiators include the familiar developer experience for React users, a focus on maintainability over raw JSON, and compatibility across Node.js (>=14) and Deno environments, providing a robust solution for Slack app development.
npm install jsx-slackVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic Slack message and a modal using the `jsxslack` tagged template literal, eliminating the need for a JSX transpiler setup. It showcases various Block Kit components and their straightforward JSX-like syntax to generate the corresponding JSON payload.
For `<a>` tags, if your `href` value might contain special characters, wrap it with `encodeURI()`: `<a href={encodeURI('https://example.com/?q=hello world')}>Link</a>`Upgrade your Node.js environment to version 14 or later to ensure compatibility and receive security updates. Check `package.json` engines field for current requirements.
Update your custom `FunctionComponent` type definitions from `JSXSlack.FunctionComponent<P>` to `JSXSlack.FunctionComponent<JSXSlack.PropsWithChildren<P>>`.
Prefer ES Modules `import` syntax. If you must use CommonJS, ensure your build setup correctly handles ESM interop. For the `jsxslack` template literal, `import { jsxslack } from 'jsx-slack'` is the recommended approach.For TypeScript, add `"jsxImportSource": "jsx-slack"` to your `compilerOptions` in `tsconfig.json`. For Babel, ensure your JSX plugin is configured to use `jsx-slack` as the runtime or pragma source.
Configure your TypeScript `tsconfig.json` with `"jsxImportSource": "jsx-slack"` in `compilerOptions`, or add `/** @jsxImportSource jsx-slack */` to the top of your JSX files. For Babel, set the `runtime` option for `@babel/plugin-transform-react-jsx`.
Ensure your project is configured for ES Modules (e.g., `"type": "module"` in `package.json`) and use `import { Blocks } from 'jsx-slack'`. If you must use CommonJS, you might need to use dynamic `import()` or adjust your bundler's configuration for ESM interop.Ensure you are using `import { jsxslack } from 'jsx-slack'` and calling it as a tagged template literal: `jsxslack`<template string>`.No dependency data recorded yet.