14. User Identity
Lesson 14: User Identity
Every RPC receives ctx as its first argument. One of the most useful properties on it is ctx.user - the identity of the connected user.
export const addNote = live((ctx, text) => {
const author = ctx.user.id; // who called this?
}); This is set during the WebSocket upgrade and is available in every RPC and stream init function. You can use it to tag data with ownership, filter results per user, or build permission logic.
Try it
- Update
addNoteto include anauthorfield set toctx.user.id - Create a
myNotesRPC that returns only notes whereauthormatchesctx.user.id
WebSocket
0
No messages yet