Installation
Set up the editor in your project with one command.
Prerequisites
- Anime.js 5 or later
- A local web server
- ES modules
The editor works only with ES modules. It does not support the UMD build of Anime.js, loaded as a global object.
Install
Set up @animatorkit/editor from the root of your project:
npx @animatorkit/editor
It automatically:
- Installs
animejsand the packages the editor needs, when they are missing. - Sets up your project, see With Vite or Without Vite.
- Creates
editor.config.json, see Server configuration. - Creates or updates the
AGENTS.mdfile of your project with a link to the agent rules of the editor, see AGENTS.md.
With Vite
The setup command adds the plugin to your Vite config, or creates vite.config.mjs when your project has none.
It should look like this:
import { defineConfig } from 'vite';
import editor from '@animatorkit/editor/vite';
export default defineConfig({
plugins: [editor()],
});
Then:
vite dev
That's it. The plugin sets up the editor in your local dev server.
Without Vite
Start the save server
The setup command adds an editor script that starts the save server. Keep it running next to your own dev server:
npm run editor
To use another port, add it to the command, for example npm run editor 7349. The editor finds the save server on its own.
Import the editor module
The editor must load before the code that creates your animations, so always import it before your animation code.
With a bundler
With webpack, Rollup, esbuild or another bundler, use a development entry that imports the editor first, then your usual entry:
// src/dev.js
import '@animatorkit/editor';
import './main.js';
Point your development build to src/dev.js, and your production build to src/main.js.
Without a bundler
When the browser loads your modules directly, map each package to its file with an import map, then import the editor first:
<script type="importmap">
{
"imports": {
"animejs": "/node_modules/animejs/dist/modules/index.js",
"@animatorkit/editor": "/node_modules/@animatorkit/editor/editor.js",
"tweaks": "/node_modules/tweaks/dist/tweaks.js",
"tweaks/gui": "/node_modules/tweaks/dist/gui/index.js",
"tweaks/gui/bridge": "/node_modules/tweaks/dist/gui/bridge.js"
}
}
</script>
<script type="module">
import '@animatorkit/editor';
import './main.js';
</script>
Docked mode script tag
To open the editor in docked mode, add this script tag at the top of the <head> of your website, before any other script:
<script src="http://localhost:7348/__tweaks__/iframe.js"></script>
Add Editor Kit
To unlock every feature of the editor with Editor Kit, run the kit command from the root of your project, and paste your Editor Kit key from your account page when it asks:
npx @animatorkit/editor kit
The command installs Editor Kit in your project and registers your key on your machine. Run it again to update Editor Kit. To go back to the free version, run npx @animatorkit/editor free.
With Vite, nothing else changes. Without Vite, import @animatorkit/editor-kit in place of @animatorkit/editor, and with an import map, map "@animatorkit/editor-kit": "/node_modules/@animatorkit/editor-kit/editor.js" in its place. Never load both, the second one stops with an error.
Editor Kit is not saved in your repository. After cloning the project, each developer with an Editor Kit seat runs npx @animatorkit/editor kit once. Developers without a seat get the free editor, with no extra step.
With Yarn 2 and later, set nodeLinker: node-modules in .yarnrc.yml. Yarn also fails to install the project without Editor Kit, so each developer and each build server needs a seat.
In a team where not everyone has a seat, use the Vite plugin, or keep the free import. On a machine without Editor Kit, code that imports @animatorkit/editor-kit fails to load.
Update
Update @animatorkit/editor with your package manager, for example npm i -D @animatorkit/editor@latest. With Editor Kit, run the kit command instead.