Skip to content

@nextvm/natives

Layer 2 of the architecture: typed wrappers around FiveM natives. Modules are forbidden from calling raw natives — they go through these abstractions.

Install

bash
pnpm add @nextvm/natives

Domain wrappers

/1 ships seven of the twelve domains from 1:

DomainClassWraps
EntityNextVMEntityGeneric entity natives — base class for Player + Vehicle
PlayerNextVMPlayer extends NextVMEntityPed natives, identifiers, health, armor, weapons
VehicleNextVMVehicle extends NextVMEntityVehicle natives, mods, fuel, damage, doors, locks
WorldWorld (static)Weather, time, blips, markers
NetworkNetwork (static)State bags, events, player utilities
RoutingRoutingServiceManaged routing buckets / instancing
VoiceVoice (static)pma-voice wrapper
PermissionsPermissions (static)ACE / IsPlayerAceAllowed

Escape hatches

SymbolPurposeSee
useNative<T>(name, ...args)Direct typed access to any FiveM nativeTick System
createBatchProcessor(opts)Spread heavy entity work across many ticksTick System

Types

TypePurpose
Vec3{ x, y, z } 3D vector used throughout the framework
EntityHandleNumeric entity handle
PlayerSourceServer source ID
BucketIdRouting bucket id
NetworkIdNetwork ID for synced entities
VehicleSeatDriver / Passenger / LeftRear / RightRear enum
VoiceProximity`'whisper'
WeatherTypeStandard GTA V weather names
BlipConfigConfig for World.createBlip
MarkerConfigConfig for World.drawMarker
RoutingInstanceConfigConfig for RoutingService.createInstance
RoutingInstanceThe handle returned by createInstance

Encapsulation pattern

typescript
// Raw FiveM:
SetEntityCoords(entity, x, y, z, false, false, false, false)

// NextVM:
entity.setPosition({ x, y, z })

The wrappers are thin — they don't add behavior, just types and ergonomics. Performance overhead is < 5% vs raw natives (Concept benchmark target).

Deferred to +

The remaining five domains from 1 are not yet shipped:

  • UI (NUI bridge)
  • Input (key bindings, commands)
  • Streaming (asset loading)
  • Camera (cam transitions)
  • Audio (sound natives)

These are documented as deferred in packages/natives/src/index.ts.

Tests

packages/natives/__tests__/ covers RoutingService, createBatchProcessor, and useNative with stubbed FiveM globals. Other domain wrappers are integration-tested via the demo bundle on a real FXServer.

Released under the LGPL-3.0 License.