The object to instantiate. Must have a guid property (set one for runtime objects).
Options for the instantiation, including the network context to send the instantiate event to
OptionalhostData: HostDataOptional data about a file to download when this object is instantiated (e.g. when instantiated via file drop)
Optionalsave: booleanWhen false, the state of this instance will not be saved in the networking backend. Default is true.
The instantiated object, or null if instantiation failed (e.g. missing guid or network context)
const cookie = ObjectUtils.createPrimitive("Cube", { color: 0xff8c00 });
cookie.guid = "cookie-prefab";
// No need to call registerPrefabProvider — syncInstantiate auto-registers it
syncInstantiate(cookie, { parent: ctx.scene, deleteOnDisconnect: false });
const idProvider = new InstantiateIdProvider("my-seed");
const instance = syncInstantiate(prefab, { context, idProvider });
The seed generates deterministic guids via UUID v5, so all clients produce identical identifiers for the clone and its children without sending them over the network.
Instantiate an object across the network. The object is cloned locally and a network message is sent so all connected clients create the same clone. Late joiners receive the message via room state replay (unless
deleteOnDisconnectis set orsaveis false).How it works internally
originalGuid, the clone'sguid, theseed, and transform dataRuntime-created prefabs (no GLB)
If the object has a
guidbut no prefab provider is registered for it,syncInstantiatewill auto-register the object as a prefab provider. This means for code-only prefabs you just need to set aguid— no manualregisterPrefabProvidercall needed, as long as all clients run the same setup code that creates the same prefab with the same guid.