
Simple and Fast Multimedia Library
The Node.js binding for SFML. Create native windows, draw 2D graphics and play audio in JavaScript or TypeScript.
npm install sfml.jsmacOS / Windows / Linux
Built on SFML 3.1 · About SFMLOpen a window, draw sprites, play music and exchange data. SFML provides the building blocks for your desktop application.
Module guidesRenderWindow · CircleShape · Color
Create a RenderWindow, draw a CircleShape, then display the frame. SFML handles the window and rendering; your JavaScript drives the loop. TypeScript declarations are included.
Follow the quick startRun this in a graphical desktop session. Escape closes the window; setImmediate leaves room for Node.js I/O between frames.
node hello.cjsconst sf = require('sfml.js');
const win = new sf.RenderWindow(
new sf.VideoMode(new sf.Vector2u(800, 600)),
'Hello, sfml.js',
);
const circle = new sf.CircleShape({ radius: 80 });
circle.setPosition(new sf.Vector2f(320, 220));
circle.setFillColor(new sf.Color(108, 190, 82));
win.setFramerateLimit(60);
function frame() {
win.handleEvents({
Closed: () => win.close(),
KeyPressed: e => {
if (e.code === sf.Keyboard.Key.Escape) win.close();
},
});
if (!win.isOpen()) return;
win.clear(new sf.Color(24, 28, 32));
win.draw(circle);
win.display();
setImmediate(frame);
}
frame();Run the examples for graphics, text, shaders, audio recording and networking.
play-nes · Desktop NES emulator with sfml.jsView source
node-sfml-demos · Game implementations using sfml.jsView source
Read the SFML C++ documentation alongside the binding’s type reference. Our guides cover promises, shared typed arrays, resource lifetime and batched rendering in Node.js.