A modern implementation of the Steamworks SDK for HTML/JS based applications.
I used greenworks for a long time and it's great, but I gave up for the following reasons.
- It's not being maintained anymore.
- It's not up to date.
- It's not context-aware.
- You have to build the binaries by yourself.
- Don't have typescript definitions.
- The API it's not trustful.
- The API implement callbacks instead of return flags or promises.
- I hate C++.
const steamworks = require('steamworks.js')
// You can pass an appId, or don't pass anything and use a steam_appid.txt file
const client = steamworks.init(480)
// Print Steam username
console.log(client.localplayer.getName())
// Tries to activate an achievement
if (client.achievement.activate('ACHIEVEMENT')) {
// ...
}
You can refer to the declarations file to check the API support and get more detailed documentation of each function.
Steamworks.js it's a native module and cannot be used by default in the renderer process. To enable the usage of native modules on the renderer process, the following configurations should be made on main.js
:
const mainWindow = new BrowserWindow({
// ...
webPreferences: {
// ...
contextIsolation: false,
nodeIntegration: true
}
})
You also have to enable some flags on chromium to make the steam overlay work. Put this code on the final of main.js
:
app.commandLine.appendSwitch('in-process-gpu')
app.commandLine.appendSwitch('disable-direct-composition')
Make sure you have the latest node.js, Rust and Clang. We also need Steam installed and running.
Install dependencies with npm install
and then run npm run build:debug
to build the library.