• Public
  • Public/Protected
  • All

Hex Kit Plugins


Hex Kit is a desktop application built on modern webapp technologies: React, Redux, and Electron. Hex Kit has it's own internal API (Redux actions) that can be used by 3rd-party plugins. With a little Javascript, new functionality (custom painting tools, generators, etc) can be added to Hex Kit.

API Overview


Hex Kit uses a URI scheme to define tiles and tilesets. The schema of the URI is the name of tileset, and the subsequent path can point to a specific file or folder in the directory structure of the tileset, i.e.:

HK-Fantasyland://HK - Wasteland/


HK-Fantasyland://HK - Grass/HK_grass_003.png

The former will randomly paint from all tiles in the HK - Wasteland folder, while the latter will specifically paint the HK_grass_003.png tile.


Hex Kit uses the offset coordinate system to designate the location of tiles. Starting in the top-left corner, the tile is designated by it's row and column. The coordinate values increase as the location moves right and downward. Red Blob Games has an execellent tutorial on the ins-and-outs of hexagon math.

0,0   0,1   0,2
   1,0   1,1   1,2
2,0   2,1   2,2

Installing the API

The Hex Kit API library is available to be installed via NPM.

npm add hexkit

Calling the API

Hex Kit uses the Redux action pattern for making changes to the map. First, you'll want to create a "store" to send actions to:

import { createStore } from 'hexkit'

let store = createStore()

Then to paint a new tile, you want to dispatch an action via the paintTiles method:

import { paintTiles } from 'hexkit'

    coord: { x: 0, y: 0 },
    layer: 0,
    uri: 'HK-Fantasyland://HK - Wasteland/'

Observing the App

The app state is inspectable as well. Use the 'getState' member of the store to get a snapshot of the current map and state of the app.

let state = store.getState()


The Redux store is often automatically relayed to a React app, like so:

import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { createStore } from 'hexkit'
import { connect } from 'react-redux' 

let store = createStore()

class MyPluginComponent extends React.Component {
    render() {
        let { appState } = this.props
        return <div>
            The first tile's URI is {appState.map.layers[0].tiles[0].source}

let MyPlugin = connect(state => ({ appState: state }))(MyPluginComponent)

    <Provider store={store}><MyPlugin /><Provider>,

Installing a new Plugin

Hex Kit looks for plugins in the Documents\Hex Kit\Plugins folder in your user's home directory.

A plugin requires a manifest.json in the root of that directory with the folllowing contents:

    "name": "Plugin Name",
    "version": "1.0"

An optional url string member may be added to the JSON manifest. For development, you can set that value to "http://localhost:8080" and use you normal Webpack workflow.

An optional devTools boolean member may be added to the JSON manifest. This will automatically open the Chrome Dev Tools window for debugging with the plugin starts.

Diverting from React/Redux

The state of the app can be read, observed, and changed with the following Electron IPC API. You can use your our state management pattern with the following IPC messages.

Get the state:


Dispatch an action to change the state:

ipcRenderer.send('api-dispatch', action)

Observe the state:

ipcRenderer.addListener('api-subscribe', () => {
    console.log('State changed!')

Implementation Patterns

"I'd like to import custom art."

Using the addTileset and setTilesetSettings actions, you can bring in your own images. Images will be snapped to hex coordinates.

Freely positioning images is not supported. Also, these tilesets will not be permanently imported, you'll need to import the art each time your plugin is initialized.

"I'd like to add a new tool to interact with the map."

You can use the setTool action and listenMouse function to create custom tools, and listen for interaction with the canvas.

Sample Plugin

An example plugin is avaiable at https://github.com/rossimo/hexkit-sample.

Generated using TypeDoc