Skip to main content

Installation

First time here?

If this is your first time using Excalibur, we recommend you start with our Excalibird tutorial where you can learn Excalibur in the browser.

Prerequisite for NPM

Install node.js

NPM is the most common way to install Excalibur

sh
npm install excalibur@latest
sh
npm install excalibur@latest

But there are several ways you can start from scratch with Excalibur

Excalibur v1 is ES modules only

Since v1 Excalibur ships only as an ES module, there is no UMD/global ex script anymore. Load it with import from a bundler or a <script type="module">. Upgrading from v0.x? See the migration guide.

Start From a Template​

If you want to get up and running quickly with a familiar toolchain, we have several templates and samples available on GitHub. These examples allow you to simply clone and start building your game! They are also a great way to learn how to integrate Excalibur into your existing toolchain.

Check out the Excalibur CLI to spin up a template or sample quickly!

Templates​

Samples​

Starting from Scratch​

There are several ways you can start from scratch with Excalibur:

note

Excalibur is a client-side library and cannot be used in a server-side Node.js, however it can be downloaded with npm.

npm Package​

note

Best for JavaScript/TypeScript projects

If you’re using Node.js or intend to use Excalibur in a primarily JavaScript project, you can install it via npm.

With Node installed, run the following on the command-line:

bash
npm install excalibur
bash
npm install excalibur

This will add excalibur to your package.json as a project dependency and will create a folder structure like:

/node_modules
/excalibur
/build
/esm
excalibur.js
excalibur.min.js
excalibur.development.js
/src/engine/excalibur.d.ts
...other files
/node_modules
/excalibur
/build
/esm
excalibur.js
excalibur.min.js
excalibur.development.js
/src/engine/excalibur.d.ts
...other files

Then import it like any other package, your bundler will pick the production or development build based on its mode:

typescript
import * as ex from 'excalibur';
typescript
import * as ex from 'excalibur';

View the excalibur package on npm.

tip

We recommend Vite for new projects, the Excalibur CLI templates are set up with it. Read more about builds and bundlers

ESM JavaScript​

Excalibur publishes an ESM build that you can use with modern ES module syntax.

html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Excalibur Vanilla JS</title>
</head>
<body>
<script type="importmap">
{
"imports": {
"excalibur": "https://unpkg.com/[email protected]/build/esm/excalibur.min.js"
}
}
</script>
<script type="module" src="src/game.js"></script>
</body>
</html>
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Excalibur Vanilla JS</title>
</head>
<body>
<script type="importmap">
{
"imports": {
"excalibur": "https://unpkg.com/[email protected]/build/esm/excalibur.min.js"
}
}
</script>
<script type="module" src="src/game.js"></script>
</body>
</html>

Then src/game.js can import Excalibur by name:

javascript
import * as ex from 'excalibur';
const game = new ex.Engine();
game.start();
javascript
import * as ex from 'excalibur';
const game = new ex.Engine();
game.start();

Script tag without a bundler​

note

Best for quick prototypes or small projects

If you do not want an import map, unpkg serves the published npm package and you can import it by URL from a module script.

It is recommended you pin your version of excalibur to a specific version like [email protected], however you can get the latest with https://unpkg.com/excalibur@latest

html
<!DOCTYPE html>
<html>
<head></head>
<body>
<script type="module">
import * as ex from 'https://unpkg.com/[email protected]/build/esm/excalibur.min.js';
const game = new ex.Engine();
game.start();
</script>
</body>
</html>
html
<!DOCTYPE html>
<html>
<head></head>
<body>
<script type="module">
import * as ex from 'https://unpkg.com/[email protected]/build/esm/excalibur.min.js';
const game = new ex.Engine();
game.start();
</script>
</body>
</html>

You can also download the compiled module from the Excalibur releases and serve it next to your game. A <script type="module"> must be served over http://, opening the file directly from disk will not work.

html
<!DOCTYPE html>
<html>
<head></head>
<body>
<script type="module">
import * as ex from './excalibur.min.js';
const game = new ex.Engine();
game.start();
</script>
</body>
</html>
html
<!DOCTYPE html>
<html>
<head></head>
<body>
<script type="module">
import * as ex from './excalibur.min.js';
const game = new ex.Engine();
game.start();
</script>
</body>
</html>

Nuget Package​

note

Best for .NET projects

If you intend to use Excalibur in a primarily .NET-based project (like Xamarin, Windows 10, etc.), you can use Nuget.

With the .NET SDK installed, run the following on the command-line:

bash
Install-Package Excalibur
bash
Install-Package Excalibur

Nuget will automatically place the Excalibur files in the Content/Scripts folder of your project:

/Content
/Scripts
excalibur.js
excalibur.min.js
excalibur.development.js
/src/engine/excalibur.d.ts
...other declaration files
/Content
/Scripts
excalibur.js
excalibur.min.js
excalibur.development.js
/src/engine/excalibur.d.ts
...other declaration files

The scripts are ES modules, load them with <script type="module"> as shown in ESM JavaScript.

See below for how to reference these files in your project after Excalibur is installed.

View the Excalibur package on Nuget.

Using a CDN​

If you want to use Excalibur in a Deno environment, use a content delivery network like esm.sh or skypack.dev. They transform our NPM package into an ES Module. That may sound complicated, but it's really just one line of code:

typescript
// index.ts
import { Engine } from 'https://esm.sh/excalibur';
// and Tada!
const game = new Engine();
game.start();
typescript
// index.ts
import { Engine } from 'https://esm.sh/excalibur';
// and Tada!
const game = new Engine();
game.start();
tip

To see the full instructions on setting up Excalibur with Deno, check out our Deno guide.

Unstable Builds​

If you want to live on the edge and get the latest unreleased and possibly unstable builds, you can download -alpha npm packages.

The latest documentation for the Unstable Builds.