Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

ReactBridge — React/Next.js Bridge

An asset by zed
The page banner background of a mountain and forest
ReactBridge — React/Next.js Bridge hero image

Quick Information

0 ratings
ReactBridge — React/Next.js Bridge icon image
zed
ReactBridge — React/Next.js Bridge

A GDScript Autoload singleton enabling bidirectional, event-driven communication between a Godot 4 WebAssembly game and a React / Next.js parent window via postMessage.Works alongside the react-godot-bridge npm package (npmjs.com/package/react-godot-bridge).USAGE:• Receive from React: ReactBridge.on_react_event.connect(_on_event)• Send to React: ReactBridge.emit_to_react("player_died", { "score": 1500 })FEATURES:- Bidirectional postMessage transport- JSON envelope protocol with secret key validation- Origin restriction for production security- Decoupled signal bus — scenes connect to signals, no browser awareness neededINSTALL:Enable the plugin in Project → Plugins, then add ReactBridge as an Autoload in Project Settings.

Supported Engine Version
4.0
Version String
1.0.1
License Version
MIT
Support Level
community
Modified Date
7 hours ago
Git URL
Issue URL

react-godot-bridge

README npm version README npm downloads README license README GitHub stars

Bidirectional, event-driven bridge between a React / Next.js app and a Godot 4 WebAssembly game running inside an <iframe>.

Designed to feel like Socket.io — you just call emit("event") and on("event"). The library handles the iframe, postMessage, and JavaScriptBridge complexity underneath.

README react-godot-bridge demo


Repository Structure

react-godot-bridge/
  npm/              ← npm package source  (published as "react-godot-bridge")
  godot-plugin/     ← Godot 4 Autoload plugin  (copy into your project)
  example/          ← Next.js demo app

React / Next.js — npm package

npm install react-godot-bridge
import { GodotBridgeProvider, GodotFrame, useGodot } from 'react-godot-bridge';

// Wrap your layout
<GodotBridgeProvider appKey={process.env.NEXT_PUBLIC_BRIDGE_KEY ?? ''}>
  <GodotFrame src="/game/index.html" className="w-full h-screen" />
  <HUD />
</GodotBridgeProvider>

// Use anywhere inside the Provider
const { emit, on } = useGodot();
emit('jump', { height: 2 });
const unsub = on('player_died', (p) => setScore(p.score as number));

See npm/README.md for full API docs.


Godot — Plugin

Copy godot-plugin/addons/react_bridge/ into your Godot project, then add the autoload in Project Settings:

[autoload]
ReactBridge="*res://addons/react_bridge/ReactBridge.gd"
# Receive from React
func _ready():
    ReactBridge.on_react_event.connect(_on_event)

func _on_event(event: String, data: Dictionary):
    if event == "jump":
        $Player.position.y += data.get("height", 1.0)

# Send to React
ReactBridge.emit_to_react("player_died", { "score": 1500 })

See godot-plugin/README.md for full docs.


How It Works

React                              Godot (iframe)
──────                             ──────────────
emit("jump", { height: 2 })
  → postMessage(envelope)    →     ReactBridge._on_message()
                                     on_react_event.emit("jump", data)
                                       $Player.position.y += data.height
                                     ReactBridge.emit_to_react("pong", {...})
  on("pong", cb) ←           ←       window.parent.postMessage(envelope)

All messages use a standard JSON envelope:

{
  "event": "jump",
  "payload": { "height": 2 },
  "metadata": { "secret": "APP_KEY", "timestamp": 1711910000 }
}

Links


Publishing

cd npm
bun install
bun run build     # outputs to dist/
npm publish

A GDScript Autoload singleton enabling bidirectional, event-driven communication between a Godot 4 WebAssembly game and a React / Next.js parent window via postMessage.

Works alongside the react-godot-bridge npm package (npmjs.com/package/react-godot-bridge).

USAGE:
• Receive from React:
ReactBridge.on_react_event.connect(_on_event)

• Send to React:
ReactBridge.emit_to_react("player_died", { "score": 1500 })

FEATURES:
- Bidirectional postMessage transport
- JSON envelope protocol with secret key validation
- Origin restriction for production security
- Decoupled signal bus — scenes connect to signals, no browser awareness needed

INSTALL:
Enable the plugin in Project → Plugins, then add ReactBridge as an Autoload in Project Settings.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
ReactBridge — React/Next.js Bridge icon image
zed
ReactBridge — React/Next.js Bridge

A GDScript Autoload singleton enabling bidirectional, event-driven communication between a Godot 4 WebAssembly game and a React / Next.js parent window via postMessage.Works alongside the react-godot-bridge npm package (npmjs.com/package/react-godot-bridge).USAGE:• Receive from React: ReactBridge.on_react_event.connect(_on_event)• Send to React: ReactBridge.emit_to_react("player_died", { "score": 1500 })FEATURES:- Bidirectional postMessage transport- JSON envelope protocol with secret key validation- Origin restriction for production security- Decoupled signal bus — scenes connect to signals, no browser awareness neededINSTALL:Enable the plugin in Project → Plugins, then add ReactBridge as an Autoload in Project Settings.

Supported Engine Version
4.0
Version String
1.0.1
License Version
MIT
Support Level
community
Modified Date
7 hours ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers