Integration Guide

Add floors.js to Gatsby

Add one line to gatsby-ssr.js. floors.js detects Gatsby's client-side routing automatically — no Gatsby plugin, no GraphQL, no npm package.

Get lifetime access — $39 See how it works

How it works

floors.js runs completely outside React and Gatsby. It patches the browser's history APIs to detect @reach/router navigation — the router Gatsby uses under the hood.

When a visitor clicks a Gatsby <Link> from /about to /blog/hello-world, @reach/router calls pushState, and floors.js picks that up automatically. No Gatsby plugin, no GraphQL, no build-time integration.

Installation

The recommended approach is to use gatsby-ssr.js to inject the script into every page at build time.

gatsby-ssr.js (recommended):
// gatsby-ssr.js
import React from "react"

export const onRenderBody = ({ setPostBodyComponents }) => {
  setPostBodyComponents([
    <script
      key="floors"
      src="https://floorsjs.com/embed.js"
      data-key="flr_..."
    />
  ])
}

Replace flr_... with your site key. The script loads asynchronously and won't affect Gatsby's build performance or hydration.

Works with Gatsby routing

Every page in your Gatsby site becomes a room in floors.js — whether it's a file-based page, programmatically generated, or a client-only route.

Configuration

All configuration is done via data- attributes on the script tag.

FAQ

Do I need a Gatsby plugin?
No. floors.js is a plain script tag. It doesn't hook into Gatsby's build pipeline, GraphQL layer, or plugin system. Just add the script and it works.
Does it work with Gatsby Cloud?
Yes. floors.js has zero build-time impact. It loads and runs entirely in the browser after your site is deployed.
What about static builds?
The script runs client-side only. Gatsby's static HTML generation is unaffected. Once the page loads in the browser, floors.js initializes and connects visitors to the current room.
Works with MDX pages?
Yes. Each MDX page gets its own URL, so each one becomes a separate room. Readers on the same page see each other and can chat.
Can I load it conditionally?
Yes. Use gatsby-browser.js and the onClientEntry API to inject the script only in certain conditions — for example, only in production.