Migrate from Objects v1 to App Context
Objects v1 is no longer supported on any current PubNub SDK. If your integration still calls an Objects v1 method, such as createUser, createSpace, or join, move it to App Context, PubNub's current metadata storage for users, channels, and memberships. There's no compatibility window. An SDK version that supports App Context doesn't also support Objects v1, so you can't run both on the same client.
Before you start
Confirm you have:
- An existing integration that calls Objects v1 methods.
- The Subscribe key for the keyset you're migrating, from the Admin Portal.
- App Context must be enabled on the keyset before you call it, and new keysets don't enable it by default.
Migrate with an AI coding assistant
If you use an AI coding assistant, paste this prompt into it to replace your Objects v1 calls. The prompt makes the assistant read this guide, list every Objects v1 call first, and stop until you confirm whether PubNub Support has finished moving your stored data. Do the PubNub Support request in Request migration of your existing data yourself.
Migrate this codebase from PubNub Objects v1 to App Context.
1. Read the migration guide first:
https://www.pubnub.com/docs/migration-guides/app-context.md
If the PubNub MCP server is connected, you can call get_general_migration_guide
instead. Where the guide and your own knowledge of PubNub SDKs disagree,
follow the guide and tell me.
2. Before you edit anything, list every Objects v1 method call, such as
createUser, updateSpace, join, or addMembers. Also list every Objects v1 event
listener and the PubNub SDK version of each client. Then show me a plan and
wait for my approval.
3. STOP and ask me two things before you change code. First, is App Context
enabled on the keyset? Second, do we need the existing Objects v1 data, and
has PubNub Support finished moving it? An SDK upgrade doesn't move that data,
and App Context can't read it until Support finishes.
show all 29 linesRequest migration of your existing data
When you upgrade your SDK to a version that supports App Context, it doesn't move your existing Objects v1 data for you. If you want to keep that data, request the move yourself:
- Go to PubNub Support and open a request.
- Include the Subscribe key for the keyset from the Admin Portal.
There's no charge for this migration. Once PubNub Support completes it, that data is reachable only through the App Context methods below, not from Objects v1 SDK methods or REST calls. Request it early, since you need the move finished before you can read that data through App Context.
Replace Objects v1 methods with App Context methods
App Context also replaces the Objects v1 concept of a "space" with a plain channel. Anywhere your integration created a space, use a channel name instead. You don't need to give a channel its own App Context metadata record just to publish or subscribe on it.
Update your code to call the App Context method for each Objects v1 method it currently calls:
User metadata methods
| Objects v1 method | App Context method |
|---|---|
createUser | setUUIDMetadata |
updateUser | setUUIDMetadata |
deleteUser | removeUUIDMetadata |
getUser | getUUIDMetadata |
getUsers | getAllUUIDMetadata |
Channel metadata methods
| Objects v1 method | App Context method |
|---|---|
createSpace | setChannelMetadata |
updateSpace | setChannelMetadata |
deleteSpace | removeChannelMetadata |
getSpace | getChannelMetadata |
getSpaces | getAllChannelMetadata |
Membership methods
| Objects v1 method | App Context method |
|---|---|
join | setMemberships |
leave | removeMemberships |
getMemberships | getMemberships |
addMembers | setChannelMembers |
removeMembers | removeChannelMembers |
getMembers | getChannelMembers |
App Context has no updateMemberships or updateMembers method. Call setMemberships or setChannelMembers again with the fields you want to change instead.
The method names above use the JavaScript SDK. Confirm the exact name for your platform in Available SDKs, or work from the current examples in each how-to:
User ID / UUID
User ID is also referred to as UUID/uuid in some APIs and server responses but holds the value of the userId parameter you set during initialization.
- Set, get, and remove user metadata
- Set, get, and remove channel metadata
- Set, get, and remove memberships
- Set, get, and remove members
Move to the unified event format
Objects v1 delivered a separate event type for each kind of change. App Context replaces them with one event, delivered to a single listener, carrying event, type, and data fields that tell you what changed and on which entity. Register that listener the same way you register any other event listener, and update your handler to branch on type instead of listening for several separate event names. Refer to App Context events for the full payload shape and your SDK's exact handler pattern.
Related tasks
- App Context. The three entity types App Context stores and how membership connects them.
- App Context events. The complete event payload and per-SDK listener patterns.
- Set, get, and remove user metadata. Current SDK examples for the user-metadata methods in this guide.
- Set, get, and remove channel metadata. Current SDK examples for the channel-metadata methods in this guide.
- Available migration guides. Every migration guide in the current documentation.