#input #windowing #filesystem #window-creation #local-filesystem #keyboard-input #game-engine


native/wasm compatibility layer for window creation, input and filesystem

10 releases (4 breaking)

0.5.0 Mar 30, 2023
0.4.1 Feb 17, 2023
0.4.0 Jan 15, 2023
0.3.1 Jan 13, 2023
0.1.0 Aug 3, 2018

#632 in Game dev

Download history 3/week @ 2023-12-18 44/week @ 2024-02-12 14/week @ 2024-02-19 61/week @ 2024-02-26 6/week @ 2024-03-04 30/week @ 2024-03-11 11/week @ 2024-03-18 214/week @ 2024-04-01

257 downloads per month
Used in 7 crates (4 directly)

MIT license

1.5K SLoC

unrust / uni-app


This library is a part of Unrust, a pure rust native/wasm game engine. This library provides a native/wasm compatibility layer for following components :

  • Window creation
  • Input (mouse + keyboard)
  • File system (local + http[s], ready-only)


uni-app = "0.4.*"
extern crate uni_app;

fn main() {
    // create the game window (native) or canvas (web)
    let app = uni_app::App::new(uni_app::AppConfig {
        size: (800, 600),
        title: "my game".to_owned(),
        vsync: true,
        show_cursor: true,
        headless: false,
        resizable: true,
        fullscreen: false,
        intercept_close_request: false,
        icon: None,
    // start game loop
    app.run(move |app: &mut uni_app::App| {
        for evt in app.events.borrow().iter() {
            // print on stdout (native) or js console (web)
            uni_app::App::print(format!("{:?}", evt));
            // exit when pressing escape
            match &evt {
                uni_app::AppEvent::KeyUp(ev) if ev.code == ScanCode::Escape => {
                _ => (),


As web app (wasm32-unknown-unknown)

Install wasm32 target :

rustup target install wasm32-unknown-unknown

Install wasm-pack and npm

Compile the demo with

wasm-pack build examples

This creates a wasm package in examples/pkg

Run the demo with

cd www
npm install
npm run start

Open your browser at http://localhost:8080/

As desktop app (native-opengl)

Run it from the www/ directory to be able to load the test.txt file :

cd www && cargo run --example basic --release


Licensed under either of

at your option.


You can contribute to this library through pull requests. If you do so, please update the CHANGELOG.md and CREDITS.md files. If you provide a new feature, consider adding an example as a tutorial/showcase.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~183K SLoC