A networking library to make multiplayer games for the Bevy game engine
  • Rust 99.5%
  • Just 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-08-16 16:05:30 -04:00
.cargo chore(build): test builds in all platforms (#1544) 2026-07-01 20:45:47 -04:00
.github ci: run doctests in parallel 2026-08-08 11:19:39 -04:00
benches Fix benchmarks and reduce steady-state allocations (#1623) 2026-08-01 15:40:39 -04:00
book fix(replication): separate target and lifecycle markers (#1682) 2026-08-12 22:18:38 -04:00
certificates chore: replace certificate script with Rust utility (#1655) 2026-08-05 06:16:05 -04:00
crates Fix ACK processing and make NACK timing configurable (#1685) 2026-08-16 16:05:30 -04:00
demos fix: refactor projectiles example (#1680) 2026-08-12 21:45:41 -04:00
docs fix(perf): avoid allocating on metrics calls (#1625) 2026-08-01 18:55:07 -04:00
examples chore: merge PeerMetadata with NetworkingMetadata (#1679) 2026-08-12 20:39:00 -04:00
.dockerignore Refactor Cargo workspace and examples (#732) 2024-12-18 08:48:04 -05:00
.gitignore Feat: Fix a few typos (#1304) 2025-11-15 23:07:43 -05:00
.pre-commit-config.yaml chore: upgrade to bevy 0.18 (#1386) 2026-01-21 20:59:43 -05:00
.release.toml chore: release lightyear 0.26 (#1387) 2026-01-21 22:18:50 -05:00
Cargo.toml chore: release 0.29 (#1673) 2026-08-10 19:23:37 -04:00
justfile fix(examples): rebuild the projectiles example (#1669) 2026-08-10 23:20:06 -04:00
LICENSE-APACHE fix some clippy warnings 2023-11-28 17:03:52 -05:00
LICENSE-MIT fix some clippy warnings 2023-11-28 17:03:52 -05:00
README.md chore: release 0.29 (#1673) 2026-08-10 19:23:37 -04:00

Lightyear

crates.io docs.rs codecov

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

Getting started

For Bevy 0.19, add Lightyear to your project with:

[dependencies]
lightyear = "0.29"

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
    • Uses aeronet for WebSocket, Steam and WebTransport support
  • Serialization
    • Lightyear uses postcard 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
    • lightyear uses bevy_replicon to enable world replication features (replication, interest management, pre-spawning, etc.)
  • 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.
    • 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)
  • Various topologies supported
    • You can run your app in client-server mode or in P2P mode. You can also have a client act as the server (host-client mode).
  • 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.29 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