Endpoint
Updates the user’s profile information. Username uniqueness is validated.
Authentication
Requires authentication via session cookie.
Request
Response
Returns the updated profile data.
Profile image URL (unchanged)
Updated username (lowercase)
Updated visibility setting
Example
import { client } from '@/lib/client';
const profile = await client.profile.update({
username: "johndoe",
bio: "Full-stack developer",
github: "johndoe",
twitter: "johndoe",
website: "johndoe.com", // Will be transformed to https://johndoe.com
isProfilePublic: true
});
console.log(profile);
Errors
CONFLICT - Username is already taken by another user
- Validation errors for invalid username format
Schema
const usernameSchema = z
.string()
.min(3, "Username must be at least 3 characters")
.max(39, "Username must be at most 39 characters")
.regex(
/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/,
"Lowercase letters, numbers, and hyphens only. Must start and end with a letter or number."
)
.refine((val) => !val.includes("--"), "Username cannot contain consecutive hyphens")
.refine((val) => !RESERVED_USERNAMES.has(val), "This username is reserved");
const updateProfileSchema = z.object({
username: usernameSchema.nullable(),
bio: z.string().max(160).nullable(),
github: z.string().max(39).nullable(),
twitter: z.string().max(15).nullable(),
website: z.string().max(200).url().nullable(),
isProfilePublic: z.boolean(),
});
Reserved Usernames
The following usernames cannot be used: login, signup, dashboard, settings, public, admin, api, rpc, u, chrome.
Source
- Schema:
lib/schema.ts:16-44
- Implementation:
server/procedures/profile.ts:23
- Router:
server/router.ts:46