MCPcopy Create free account
hub / github.com/vercel/examples / getUserId

Function getUserId

python/vibe-coding-ide/frontend/src/lib/user.ts:1–15  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1export function getUserId(): string {
2 if (typeof window === 'undefined') return 'user_local'
3 try {
4 const KEY = 'nfca_user_id'
5 const existing = window.localStorage.getItem(KEY)
6 if (existing && existing.trim()) return existing
7 const generated = `user_${Date.now().toString(36)}_${Math.random()
8 .toString(36)
9 .slice(2, 10)}`
10 window.localStorage.setItem(KEY, generated)
11 return generated
12 } catch {
13 return 'user_local'
14 }
15}
16
17export function ensureGlobalUserId(): string {
18 const id = getUserId()

Callers 3

EditorPaneFunction · 0.90
ProjectsProviderFunction · 0.90
ensureGlobalUserIdFunction · 0.85

Calls 1

toStringMethod · 0.80

Tested by

no test coverage detected