Give each user their own instance of an object. The simplest way is to pass the id yourself:
await state("Users", userId).put({ preferences });If the id is already a route parameter, map the object to it once and drop the argument everywhere else:
1apiker.init({2 routes: { "/users/:userId/preferences": handler },3 objectStateMapping: { Users: "userId" },4 objects: ["Common", "Users"],5 exports6});7 8// inside the handler, this now resolves to the :userId instance9await state("Users").put({ preferences });For anonymous visitors, map to signedIp instead — a stable, signed hash of the caller's address that is safe to use as a key.
Do not put every user in one instance. Cloudflare serialises requests to a single instance, so a shared one becomes the bottleneck for your whole API.


