NEOLearn

Plugins

Organise an app into plugins, write your own with the Plugin trait, group them with PluginGroup, and configure or disable the plugins in DefaultPlugins and MinimalPlugins.

Updated October 20, 2026

On this page

A plugin is a piece of an app packaged as one unit: the systems, resources, messages and observers for one feature, added with a single add_plugins call. The engine's features (windowing, rendering, input, audio) are plugins, and so is a NEO game. Split your own game into plugins by feature: PlayerPlugin, EnemyPlugin, UiPlugin.

Write a plugin#

Implement Plugin. build receives the App and does what main would otherwise do:

Rust
use neo::prelude::*;

pub struct EnemyPlugin {
    pub spawn_every: f32,
}

impl Plugin for EnemyPlugin {
    fn build(&self, app: &mut App) {
        app.insert_resource(SpawnTimer(Timer::from_seconds(self.spawn_every, TimerMode::Repeating)))
            .add_message::<EnemyDied>()
            .add_systems(Update, (spawn_enemies, move_enemies));
    }
}

#[derive(Resource)]
struct SpawnTimer(Timer);

#[derive(Message)]
struct EnemyDied;

fn spawn_enemies(time: Res<Time>, mut timer: ResMut<SpawnTimer>, mut commands: Commands) {
    if timer.0.tick(time.delta()).just_finished() {
        commands.spawn((Name::new("Enemy"), Transform::default()));
    }
}

fn move_enemies() {}

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, EnemyPlugin { spawn_every: 2.0 }))
        .run();
}

A unit struct can be added by name: app.add_plugins(PlayerPlugin). A function fn(&mut App) also works as a plugin, which is handy for small modules:

Rust
pub fn hud_plugin(app: &mut App) {
    app.add_systems(Startup, spawn_hud);
}

app.add_plugins(hud_plugin);

The Plugin trait#

MethodWhen it runsUse it for
build(&self, app)When the plugin is added. Required.Registering systems, resources, messages, observers and other plugins.
ready(&self, app) -> boolPolled before finish until it returns true.Waiting for something asynchronous, such as the GPU device.
finish(&self, app)After every plugin has been built and is ready.Setup that needs resources other plugins add in their build.
cleanup(&self, app)After every finish.Final tidying.
name(&self)The plugin's name in logs and errors. Defaults to the type name.
is_unique(&self) -> booltrue by default: adding the plugin twice is an error. Return false to allow it.

Check for another plugin with app.is_plugin_added::<OtherPlugin>() when yours works with or without it.

Plugin groups#

A PluginGroup adds several plugins in order. Build one with PluginGroupBuilder:

Rust
use neo::app::PluginGroupBuilder;

pub struct GamePlugins;

impl PluginGroup for GamePlugins {
    fn build(self) -> PluginGroupBuilder {
        PluginGroupBuilder::start::<Self>()
            .add(PlayerPlugin)
            .add(EnemyPlugin { spawn_every: 2.0 })
            .add(hud_plugin)
    }
}

DefaultPlugins and MinimalPlugins#

GroupWhat it is
DefaultPluginsEverything a windowed game needs: logging, task pools, time, transforms, input, windowing, assets, scenes, rendering, 2D and 3D, text, UI, glTF, audio, gamepads, animation, gizmos, states and picking. Which plugins are included follows the neo crate's cargo features.
MinimalPluginsTask pools, frame count, time and a schedule runner. For servers, tools and tests with no window.

Configure or remove members of a group before adding it:

Rust
use neo::{log::LogPlugin, window::WindowPlugin};

App::new()
    .add_plugins(
        DefaultPlugins
            .set(WindowPlugin {
                primary_window: Some(Window {
                    title: "My Game".into(),
                    ..default()
                }),
                ..default()
            })
            .disable::<LogPlugin>(),
    )
    .run();
MethodWhat it does
group.set(plugin)Replaces a member with your configured value, and returns the group's builder.
group.build()The group's PluginGroupBuilder, for the methods below.
builder.disable::<T>(), builder.enable::<T>()Leaves a member out, or puts it back.
builder.add_before::<T>(plugin), builder.add_after::<T>(plugin)Inserts a plugin at a position.

Examples#

Run these from the engine core's workspace:

ExampleWhat it shows
cargo run --example pluginA configurable plugin that prints a message on a timer.
cargo run --example plugin_groupA plugin group, and disabling members of a group.

Next steps#