# Migrating from ox_inventory

Scripts written for ox_inventory keep working: the inventory answers `exports.ox_inventory` calls with the same names and arguments, fires the ox events, and imports your ox data at start.

:::::steps
### Turn the ox_inventory folder into the bridge

Stop ox_inventory. Delete everything in the `ox_inventory` folder **except `data/`**, then copy `bridge/ox_inventory/fxmanifest.lua` from koja-inventory-v2 into it. The folder keeps the `ox_inventory` name, so `dependency 'ox_inventory'` in other resources and ESX's ox mode keep working, and it serves your old `data/*.lua` files.

### Update server.cfg

```cfg title="server.cfg"
ensure koja-inventory-v2
ensure ox_inventory
```

The bridge must start after the inventory.

### Start the server

Your ox items, weapons, ammo, attachments, shops, stashes and crafting benches are imported from `data/` (`Config.Ox.importItems`, `importShops`, `importStashes`, `importCrafting`). The console banner shows how many items came from ox.

Grid sizes for imported items are guessed: by weight for normal items (up to 250 g is 1x1, up to 1 kg 1x2, up to 3 kg 2x2, heavier 3x2) and by weapon type for weapons (rifles 4x2, snipers and launchers 5x2, shotguns 5x1, SMGs 3x2, pistols 2x2, long melee 1x3). To change a size, define the item in `shared/items.lua`.

### Players

Each player's ox inventory is imported the first time they join (from `users.inventory` on ESX or `players.inventory` on QBCore), when `Config.Ox.migratePlayers` is on.

To move everything at once, including offline players, stashes, trunks and gloveboxes, run this in the server console:

```cfg
koja_migrate_ox
```

`koja_migrate_ox force` overwrites inventories that were already imported. Items that do not fit the new grid are kept and placed as soon as there is room.
:::::

## What stays compatible

- **Server exports**: `Items`, `AddItem`, `RemoveItem`, `GetItem`, `GetItemCount`, `Search`, `GetSlot`, `GetSlotWithItem`, `GetSlotsWithItem`, `GetSlotIdWithItem`, `GetSlotIdsWithItem`, `GetItemSlots`, `GetSlotForItem`, `GetEmptySlot`, `GetInventory`, `GetInventoryItems`, `GetContainerFromSlot`, `CanCarryItem`, `CanCarryAmount`, `CanCarryWeight`, `CanSwapItem`, `SetItem`, `SetMetadata`, `SetDurability`, `SetMaxWeight`, `ClearInventory`, `RegisterStash`, `CreateTemporaryStash`, `CustomDrop`, `forceOpenInventory`, `InspectInventory`, `RegisterShop`, `ConfiscateInventory`, `ReturnInventory`, `GetCurrentWeapon`, `UpdateVehicle`, `registerHook`, `removeHooks`, `setPlayerInventory`.
- **Client exports**: `openInventory`, `closeInventory`, `openNearbyInventory`, `Items`, `Search`, `GetItemCount`, `GetPlayerItems`, `GetPlayerWeight`, `GetPlayerMaxWeight`, `GetSlotWithItem`, `GetSlotsWithItem`, `GetSlotIdWithItem`, `GetSlotIdsWithItem`, `getCurrentWeapon`, `useSlot`, `useItem`, `giveItemToTarget`, `weaponWheel`.
- **Events**: `ox_inventory:usedItem`, `ox_inventory:openedInventory`, `ox_inventory:closedInventory` on the server, `ox_inventory:currentWeapon` on the client, state bags `invOpen` and `invBusy`.
- **Hooks**: `swapItems`, `openInventory`, `usingItem` and `createItem` with `itemFilter` and `inventoryFilter`.
- **Usable items**: ox `client.export` / `server.export` on the item definition.
- **ESX**: with the bridge, ESX runs in ox mode, so `xPlayer.addInventoryItem`, `removeInventoryItem`, `getInventoryItem`, `canCarryItem`, `getInventory()` and account money use this inventory.

Slots are stable numbers per inventory, so a `slot` from `GetSlotWithItem` can be passed back to `RemoveItem` or `SetMetadata`. The `inv` argument accepts a player id, a stash name, `{ id = name, owner = identifier }`, `'trunk' .. plate`, `'glove' .. plate` or a container id like `stash:name`.

See the [Developer API](/new/inventory-v2/api) for the extra exports this inventory adds.
