Plugins
KAPLAY uses a flexible plugin system that helps you extend the library’s functionality with new methods, constants, or even new components.
Let’s take a look at how the default plugin myPlugin()
is implemented.
// k is the KAPLAY context, what kaplay() returns
function myPlugin(k) {
return {
hi() {
k.debug.log("Hi from myPlugin!");
},
};
}
Now you can use the plugin in your game:
const k = kaplay({
plugins: [myPlugin],
});
k.hi(); // from myPlugin
Creating a plugin
We recommend using our templates:
kaplay-plugin-template
kaplay-plugin-template-ts
(for TypeScript)
Both are minimal and simple templates for create and publish plugins on NPM.
Browse Plugins
Community Plugins
- kaplanck - Plank.js physics for KAPLAY
- kaplay-rapier-physics Rapier physics for KAPLAY
You can explore all plugins made by the community in our Discord.