Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @speee-js/jsx-slack with all npm packages installed. Try it out:

var jsxSlack = require("@speee-js/jsx-slack")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@speee-js/jsx-slack v2.2.0

Build JSON object for Slack Block Kit surfaces from JSX


CircleCI Codecov npm LICENSE

Build JSON object for Slack block kit surfaces from JSX.

:sparkles: We have sparkling jsx-slack v2! :sparkles: ▶︎ See highlight of v2

:point_right: Try our REPL demo in


See references to dive into jsx-slack deeply.


When developing Slack-integrated app, continuous maintenance of the rich contents is a difficult task. A team member must read and write JSON with deep knowledge about specifications of payload for Slack API.

We believe JSX-based template well-known in front-end development would enhance a developer experience of Slack app.

Project goal

A project goal is creating an interface to compose contents for Slack with keeping code maintainability by using JSX.

jsx-slack would allow composing contents with simple and predictable HTML-like markup. It helps in understanding the structure of complex contents and interactions.


We require Node.js >= 10. If you are using TypeScript, we also require TS >= 3.7.

# npm
npm install --save @speee-js/jsx-slack
# yarn
yarn add @speee-js/jsx-slack


Quick start: Template literal

Do you hate troublesome setting up for JSX? All right. We provide jsxslack tagged template literal to build blocks right out of the box.

It allows the template syntax almost same as JSX, powered by HTM (Hyperscript Tagged Markup). Setting for transpiler and importing built-in components are not required.

This is a simple example of the template function just to say hello to someone.

import { jsxslack } from '@speee-js/jsx-slack'

export const exampleBlock = ({ name }) => jsxslack`
      Hello, <b>${name}</b>!

JSX Transpiler

When you want to use jsx-slack with JSX transpiler, you have to set up to use imported our parser JSXSlack.createElement or its alias JSXSlack.h.

/** @jsx JSXSlack.h */
import { JSXSlack, Blocks, Section } from '@speee-js/jsx-slack'

export const exampleBlock = ({ name }) => (
      Hello, <b>{name}</b>!

▶︎ How to setup JSX transpiler (Babel / TypeScript)

Use template in Slack API

After than, just use created template in Slack API. We are using the official Node SDK @slack/web-api in this example. See also Slack guide.

import { WebClient } from '@slack/web-api'
import { exampleBlock } from './example'

const web = new WebClient(process.env.SLACK_TOKEN)
    channel: 'C1234567890',
    blocks: exampleBlock({ name: 'Yuki Hattori' }),
  .then((res) => console.log('Message sent: ', res.ts))

It would post a simple Slack message like this:

Block Kit as components

Slack has recommended to use Block Kit for building tempting messages and modals.

By using jsx-slack, you can build a template with piling up Block Kit blocks by JSX. It is feeling like using components in React or Vue.

For messaging

    <p>Enjoy building blocks!</p>
        <a href="">@speee-js/jsx-slack</a>
      <br />
      <i>Build JSON for Slack Block Kit from JSX</i>
    <Image src="" alt="Speee, Inc." />
    Maintained by <a href="">Yuki Hattori</a>
    <img src="" alt="yhatt" />
  <Divider />
    <Button url="">GitHub</Button>
    <Button url="">npm</Button>

For modal

<Modal title="My first modal" close="Cancel">
      <strong>It's my first modal!</strong> :sunglasses:
    <p>jsx-slack also has supported Slack Modals.</p>
  <Divider />

  <Input type="text" name="subject" label="Subject" required />
  <Textarea name="message" label="Message" maxLength={500} />

    label="Share with..."
    include={['public', 'im']}

  <Input type="hidden" name="postId" value="xxxx" />
  <Input type="submit" value="Send" />

For home tab

  <Image src="" alt="home" />
    <b>Welcome back to my home!</b> :house_with_garden:
  <Divider />
  <Section>What's next?</Section>
    <RadioButtonGroup actionId="next">
      <RadioButton value="tickets" checked>
        <b>See assigned tickets</b> :ticket:
          <i>Check your tickets to start your work.</i>
      <RadioButton value="reminder">
        <b>Remind a task later</b> :memo:
          <i>I'll remember a task for you.</i>
      <RadioButton value="pomodoro">
        <b>Start pomodoro timer</b> :tomato:
          <i>Get focused on your time, with tomato!</i>
    <Button actionId="start" style="primary">
      Start working


Examples by use cases

Ported from templates for Block Kit Builder.



App Home


As like as React, jsx-slack provides <Fragment> (<JSXSlack.Fragment>) component for higher-order component (HOC) consited of multiple blocks or elements.

For example, you can define the custom block by grouping some blocks with <Fragment> if you were using JSX transpiler.

Let's say defines <Header> custom block that is consisted by <Section> and <Divider>.

/** @jsx JSXSlack.h */
import { JSXSlack, Fragment } from '@speee-js/jsx-slack'

const Header = ({ children }) => (
    <Divider />

Now the defined block can use in <Blocks> as like as the other blocks:

    <i>jsx-slack custom block</i> :sunglasses:
  <Section>Let's build your block.</Section>

Short syntax for Babel transpiler

Babel transpiler can use the short syntax <></> for fragments. See how to setup JSX transpiler.

/** @jsx JSXSlack.h */
/** @jsxFrag JSXSlack.Fragment */
import { JSXSlack } from '@speee-js/jsx-slack'

const Header = ({ children }) => (
    <Divider />

In the case of template literal tag

jsxslack template literal tag has built-in fragments support so <Fragment> does not have to use.

// Header.js
import { jsxslack } from '@speee-js/jsx-slack'

export const Header = ({ children }) => jsxslack`
  <Divider />

A defined component may use in jsxslack tag as below:

import { jsxslack } from '@speee-js/jsx-slack'
import { Header } from './Header'

      <i>jsx-slack custom block</i> :sunglasses:
    <Section>Let's build your block.</Section>

Please notice to a usage of component that has a bit different syntax from JSX.

Frequently questions

Is jsx-slack the state of production-ready?

Of course! In our workspace, we are developing Slack custom app for internal with providing great UX powered by jsx-slack. And some apps published in Slack app directory are also using jsx-slack in production.

Do you have an app with jsx-slack in public? Please let us know your great app!

Can I develop Slack app only using jsx-slack?

No. jsx-slack just generates JSON for Slack API. You have to send generated message and control interaction with Slack by yourself.

Don't worry; you can use jsx-slack together with helpful libraries: Bolt framework for JavaScript (recommended), Slack Node SDK, and third-party library (e.g. BotKit, Bottender).

Is this working based on React?

No, jsx-slack has very similar API to React but is not based on React, because our library doesn't need to use some features provided by React: incremental updates, event handling, reference to the rendered JSON, and component class.

Nevertheless, jsx-slack can use React's methodology (composition of components) through JSX and the basic JavaScript function. In addition, we can follow up rapidly-evolving Slack Block Kit by keeping the smallest requirements without depending on React.

FYI there are some projects based on React (react-reconciler) to generate or manage Slack interactions: phelia framework, react-chat-renderer (< v0.1.0), and rebot. You should use them if you want to use React ecosystem.

Similar projects

  • phelia - :zap: A reactive Slack application framework.
  • react-chat-renderer - React renderer implementation for building rich Slack messages using JSX
  • slack-blockx - jsx for Slack block-kit


Managed by Speee, Inc. Speee, Inc. (@speee)

  • @yhatt Yuki Hattori (@yhatt) - Maintainer


MIT License

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free