Back to rankings

cBournhonesque/lightyear

Rustcbournhonesque.github.io/lightyear/book

A networking library to make multiplayer games for the Bevy game engine

bevygamedevmultiplayernetworkingrust
Star Growth
Stars
1.1k
Forks
148
Weekly Growth
Issues
76
5001k
Nov 2023Sep 2024Aug 2025Jul 2026
Artifactscrates.iocargo add lightyear
README

Lightyear

crates.io docs.rs codecov

A library for writing server-authoritative multiplayer games with Bevy. Compatible with wasm via WebTransport.

https://github.com/cBournhonesque/lightyear/assets/8112632/7b57d48a-d8b0-4cdd-a16f-f991a394c852

Demo using one server with 2 clients. The entity is predicted (slightly ahead of server) on the controlling client and interpolated (slightly behind server) on the other client. The server only sends updates to clients 10 times per second but the clients still see smooth updates.

Getting started

You can first check out the examples.

To quickly get started, you can follow this tutorial, which re-creates the simple_box example.

You can also find more information in this WIP book.

Repository layout

Workspace crate sources live under crates/, grouped by role. Directory names drop the lightyear_ prefix, but Cargo package names keep it.

  • crates/io: low-level IO links and backends such as aeronet, link, udp, crossbeam, websocket, and webtransport
  • crates/connection: connection abstractions and adapters such as connection, raw_connection, netcode, and steam
  • crates/core: the top-level lightyear crate plus shared core, sync, utils, and frame interpolation crates
  • crates/inputs: input crates such as inputs, inputs_native, input_bei, and inputs_leafwing
  • crates/replication: replication, prediction, and interpolation crates
  • crates/transport: serialization, transport, and message crates
  • crates/integration: Bevy ecosystem integrations such as Avian
  • crates/platform, crates/deterministic, crates/tools, and crates/tests: platform support, deterministic replication, tooling, and test support

Games

Features

  • Transport-agnostic: Lightyear is compatible with a number of IO backends, including:
    • UDP sockets
    • WebTransport (using QUIC): available on both native and wasm!
    • WebSocket: available on both native and wasm!
    • Steam: use the SteamWorks SDK to send messages over the Steam network
  • Serialization
    • Lightyear uses bincode as a default serializer, but you can provide your own serialization function
  • Message passing
    • Lightyear supports sending packets with different guarantees of ordering and reliability through the use of channels.
    • Packet fragmentation (for messages larger than ~1200 bytes) is supported
  • Input handling
    • Lightyear has special handling for player inputs (mouse presses, keyboards). They are buffered every tick on the Client, and lightyear makes sure that the client input for tick N will be processed on tick N on the server. Inputs are protected against packet-loss: each packet will contain the client inputs for the last few frames.
    • With the leafwing feature, there is a special integration with the leafwing-input-manager crate, where your leafwing inputs are networked for you!
    • Also supports the bevy-enhanced-input crate!
  • Deterministic replication
    • Lightyear supports deterministic replication when only inputs are replicated. The simulation needs to be deterministic. The deterministic replication is compatible with both lockstep and prediction/rollback.
  • World Replication
    • Entities that have the Replicate bundle will be automatically replicated to clients.
  • Advanced replication
    • Client-side prediction: with just a one-line change, you can enable client-prediction with rollback on the client, so that your inputs can feel responsive
    • Snapshot interpolation: with just a one-line change, you can enable Snapshot interpolation so that entities are smoothly interpolated even if replicated infrequently.
    • Client-authoritative replication: you can also replicate entities from the client to the server. The authority over the entity is transferable between the client and the server.
    • Pre-spawning predicted entities: you can spawn Predicted entities on the client first, and then transfer the authority to the server. This ensures that the entity is spawned immediately, but will still be controlled by the server.
    • Entity mapping: lightyear also supports replicating components/messages that contain references to other entities. The entities will be mapped from the local World to the remote World.
    • Interest management: lightyear supports replicating only a subset of the World to clients. Interest management is made flexible by the use of Rooms
    • Input Delay: you can add a custom amount of input-delay as a trade-off between having a more responsive game or more miss-predictions
    • Bandwidth Management: you can set a cap to the bandwidth for the connection. Then messages will be sent in decreasing order of priority (that you can set yourself), with a priority-accumulation scheme
    • Lag Compensation is available so that predicted entities can interact with interpolated entities (used most often for fps games)
  • Configurable
    • Lightyear is highly configurable: you can configure the size of the input buffer, the amount of interpolation-delay, the packet send rate, etc.
  • Observability
    • Lightyear uses the tracing and metrics libraries to emit spans and logs around most events ( sending/receiving messages, etc.).
  • Examples
    • Lightyear has plenty of examples demonstrating all these features, as well as the integration with other bevy crates such as avian

Supported bevy version

Lightyear Bevy
0.28 0.19
0.26-0.27 0.18
0.25 0.17
0.20-0.24 0.16
0.18-0.19 0.15
0.16-0.17 0.14
0.10-0.15 0.13
0.1-0.9 0.12
Related repositories
bevyengine/bevy

A refreshingly simple data-driven game engine built in Rust

Rustcrates.ioApache License 2.0bevygamedev
bevy.org
47.3k4.7k
valence-rs/valence

A Rust framework for building Minecraft servers.

Rustcrates.ioMIT Licensegamedevminecraft
valence.rs
3.3k165
rivet-gg/rivet

🔩 Serverless for stateful backends

Rustcrates.ioApache License 2.0game-developmentmultiplayer
rivet.gg
3.2k80
avianphysics/avian

ECS-driven 2D and 3D physics engine for the Bevy game engine.

Rustcrates.ioApache License 2.0bevyphysics
crates.io/crates/avian3d
3.1k265
bevy-cheatbook/bevy-cheatbook

Unofficial Reference Book for the Bevy Game Engine

Rustcrates.iobevydocumentation
bevy-cheatbook.github.io
2.4k136
Jondolf/avian

ECS-driven 2D and 3D physics engine for the Bevy game engine.

Rustcrates.ioApache License 2.0bevyphysics
crates.io/crates/avian3d
1.9k133
fishfolk/jumpy

Tactical 2D shooter in fishy pixels style. Made with Rust-lang 🦀 and Bevy 🪶

Rustcrates.ioOthergamemodding
fishfolk.org/games/jumpy/
1.9k130
vladbat00/bevy_egui

This crate provides an Egui integration for the Bevy game engine. 🇺🇦 Please support the Ukrainian army: https://savelife.in.ua/en/

Rustcrates.ioMIT Licensebevyegui
1.4k338
djeedai/bevy_hanabi

🎆 Hanabi — a GPU particle system plugin for the Bevy game engine.

Rustcrates.ioApache License 2.0rustparticle
1.4k119
zkat/big-brain

Utility AI library for the Bevy game engine

Rustcrates.ioOtherbevy
1.3k81
NiklasEi/bevy_game_template

Template for a Bevy game including CI/CD for web, Windows, Linux, macOS, iOS and Android

Rustcrates.ioCreative Commons Zero v1.0 Universalbevygame-development
niklasei.github.io/bevy_game_template/
1.1k107
localgpt-app/localgpt

Local AI assistant, dreaming explorable worlds.

Rustcrates.ioApache License 2.0agentai
localgpt.app
1.1k101