npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@node-3d/glfw

v7.1.1

Published

GLFW for Node.js

Readme

GLFW for Node.js

This is a part of Node3D project.

NPM Lint Test Cpplint

npm install @node-3d/glfw

Node.js addon with GLFW3 bindings.

Example

  • GLFW version 3.4.0 backend.
  • Exposes low-level GLFW interface.
  • Multiple windows for a single Node.js process.
  • Able to switch to fullscreen and back.
  • Provides GlfwWindow, a native GLFW window wrapper for direct window/control work.
  • Keeps legacy Window and Document classes for compatibility with older code.
  • Leaves browser-like Window/Document/canvas behavior to @node-3d/core.

The package has named exports only. Use glfw for the raw native bindings, and import GlfwWindow directly for native window management.

import { GlfwWindow, glfw } from '@node-3d/glfw';

const wnd = new GlfwWindow({ title: 'GLFW Test', vsync: true });

wnd.loop(() => {
	if (wnd.shouldClose || wnd.getKey(glfw.KEY_ESCAPE)) {
		process.exit(0);
		return;
	}
	
	glfw.testScene(wnd.width, wnd.height);
});

Note: this addon uses N-API, and therefore is ABI-compatible across different Node.js versions. Addon binaries are precompiled and there is no compilation step during the npm install command.

Prebuilt addon binaries are provided for Windows x64/ARM64, Linux x64/ARM64, and macOS x64/ARM64.

Concern Separation

@node-3d/glfw is the GLFW layer:

  • glfw exposes the raw native GLFW binding and constants.
  • GlfwWindow wraps a native GLFW window handle with event, size, mode, context, frame, and loop helpers.
  • Window and Document remain as legacy compatibility classes.

Browser-style application compatibility belongs in @node-3d/core:

  • BrowserWindow owns browser-style requestAnimationFrame.
  • BrowserDocument owns document/canvas/image/WebGL compatibility.
  • init() wires globalThis.window, globalThis.document, WebGL, Image, and other browser-like globals.

GLFW

This is a low-level interface, where most of the stuff is directly reflecting GLFW API. GLFW does NOT EXPOSE OpenGL commands, it only controls the window-related setup and resources. To access OpenGL/WebGL API you can use @node-3d/webgl or any other similar addon.

Aside from several additional features, this addon directly exposes the GLFW API to JS. E.g.:

DBG_EXPORT JS_METHOD(pollEvents) {
	glfwPollEvents();
	RET_GLFW_VOID;
}

Nothing is added between you and GLFW, unless necessary or explicitly mentioned.

  • All glfw* functions are accessible as glfw.*. E.g. glfwPollEvents -> glfw.pollEvents.
  • All GLFW_* constants are accessible as glfw.*. E.g. GLFW_TRUE -> glfw.TRUE.
  • Higher-level helpers are separate named exports. E.g. import { GlfwWindow } from '@node-3d/glfw'.
  • Method glfw.createWindow takes some additional arguments. This is mostly related to JS events being generated from GLFW callbacks, and here's where you provide an Emitter object.
  • Pointers are directly exposed as numbers to JS and are expected as arguments in specific methods. Such as, glfw.createWindow returns a number (pointer), and then you provide it back to e.g. glfw.setWindowTitle.

See this example for raw GLFW calls.

The public entrypoint exports glfw, GlfwWindow, legacy Window, legacy Document, and event/window option types. The lower-level raw API is on glfw; the classes are imported directly.


class GlfwWindow

import { GlfwWindow } from '@node-3d/glfw';

const wnd = new GlfwWindow({ title: 'GLFW Test', vsync: true });

This class manages native window objects and their events. It can also switch between fullscreen, borderless and windowed modes. It does not implement browser requestAnimationFrame or document/canvas compatibility.

The first window creates an additional invisible root-window for context sharing (so that you can also close any window and still keep the root context). The platform context (pointers/handles) for sharing may be obtained when necessary.

See ts/window.ts for more details.

Legacy Window remains available as a subclass with requestAnimationFrame and cancelAnimationFrame. New browser-style code should use BrowserWindow from @node-3d/core.


Legacy class Document

import { Document } from '@node-3d/glfw';

const doc = new Document({ title: 'GLFW Test', vsync: true });

Document inherits from legacy Window and has the same features in general. It exposes additional APIs to mimic the content of web document. There are some tricks to provide WebGL libraries with necessary environment. Document is kept for compatibility; new browser-style code should use BrowserDocument from @node-3d/core. Other web libraries may work too, but may require additional tweaking.

See ts/document.ts for more details.


Extras

  • glfw.hideConsole(): void - tries to hide the console window on Windows.
  • glfw.showConsole(): void - shows the console window if it has been hidden.
  • glfw.drawWindow(w: number, cb: (timestamp: number) => void): void - this is a shortcut to call pollEvents, then cb, and then swapBuffers. GlfwWindow#drawWindow wraps this call and supplies the window handle for you.
  • glfw.platformDevice(): number - returns the native display or device handle, or whatever is similar on other systems.
  • glfw.platformWindow(w: number): number - returns the window HWND on Windows, or whatever is similar on other systems.
  • glfw.platformContext(w: number): number - returns the window WGL Context on Windows, or whatever is similar on other systems.

Binary Origin

Release archives are built by this repository's public GitHub Actions workflows.

Attestations: https://github.com/node-3d/glfw/attestations

To verify a downloaded archive:

gh release download <tag> -R node-3d/glfw -p <platform>.gz
gh attestation verify <platform>.gz -R node-3d/glfw