Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


nim-glfw provides a nice idiomatic Nim API to GLFW, the cross-platform OpenGL, OpenGL ES & Vulkan library.

Not all functionality is available through the Nim API yet; in those cases you can just use the native C bindings directly (by importing glfw/wrapper). Please also raise a ticket about the missing functionality so we can add it, or even better yet, give a shot at implementing it yourself and raise a PR! 😄


Versioning follows the x.y.z.w scheme, where x.y.z corresponds to the GLFW version being wrapped (e.g. 3.3.0) and w to the patch version of the Nim wrapper (e.g.


The best way to install the latest version of the package is via nimble:

nimble install glfw


All examples except minimal.nim and events.nim depend on nim-glm.

You can install nim-glm with the following command:

nimble install glm

Compile and run any of the examples by running the following command in the examples directory:

nim c -r -d:glfwStaticLib <example>

Alternatively, you can invoke the examplesStatic or examples (for dynamic linking) nimble task in the project root directory to compile all examples:

nimble examplesStatic


A minimal example to display a window for one second and then terminate:

import os, glfw

proc main =

  var c = DefaultOpenglWindowConfig
  c.title = "Minimal Nim-GLFW example"

  var w = newWindow(c)




Check out the examples directory for more complex examples!

Statically linking to GLFW

To link statically against GLFW (the C sources are bundled within the module), define the conditional symbol glfwStaticLib (-d:glfwStaticLib or --define:glfwStaticLib).


No documentation exists currently, but a symbol list can be generated by invoking these commands from the root directory:

nim doc glfw
nim doc glfw/wrapper

Checking out the examples is probably the best way to get started with the library. If you have some familiarity with GLFW, reading the official GLFW documentation in conjunction with the Nim sources should make everything clear.

Creating high-quality documentation is a lot of work, so if you would like to help the project, writing documentation would be a great way to contribute!


ephja: Original author and maintainer until v3.2.

johnnovak: Current maintainer and ports of some of the official GLFW examples.

def-: Support for static linking.

AntonioArtigas: GLFW 3.3 update.