John Doe
I love donuts!!
The cohera auth module Or alternatively your own usermanagement that provides the user data. See here how to configure that.
If you didn’t include the User Profiles module during initial project setup, you can add it at any time:
cohera module add user-profilesEach userprofile will be accessible under /profile/{username}
Display user profiles with these components. They automatically adapt to which fields are available depending on your field configuration and what the user filled out.
You can use these components in two ways:
userID and let the component fetch the user datafirstName, lastName, picture, bio, etc.)A card preview of the profile. By default if you click on it it opens the ProfilePopup
Example Usage:
<!-- With userID - component fetches the data --><ProfileCard userID="<userId>" />
<!-- With direct field values --><ProfileCard firstName="Jane" lastName="Smith" picture="/images/jane.jpg" bio="Software engineer"/>Preview:
I love donuts!!
Example Usage:
<!-- With userID - component fetches the data --><ProfilePopup userID="<userId>" />
<!-- With direct field values --><ProfilePopup firstName="Jane" lastName="Smith" picture="/images/jane.jpg" bio="Software engineer"/>Preview:
Example Usage:
<!-- With userID - component fetches the data --><ProfilePage userID="<userId>" />
<!-- With direct field values --><ProfilePage firstName="Jane" lastName="Smith" picture="/images/jane.jpg" bio="Software engineer" location="New York, US" website="https://janesmith.dev"/>Preview:
London, UK
Mathematician and early programmer.
A settings page where users can edit their own profile information (picture, first name, last name, bio, etc.) and privacy settings.
Example Usage:
<ProfileSettingsPage />Preview:
The settings page automatically:
required or optional in your configurationConfigure what fields to use and their privacy settings. Each field can be required, optional or disabled.
Example in cohera.config.ts:
export default { userProfiles: { fields: { firstName: { requirement: "required", defaultVisibility: "public", allowUserControl: false, // Users cannot change visibility }, lastName: { requirement: "required", defaultVisibility: "public", allowUserControl: false, }, picture: { requirement: "optional", defaultVisibility: "public", allowUserControl: true, // Users can change visibility }, bio: { requirement: "optional", defaultVisibility: "members-only", allowUserControl: true, }, email: { requirement: "optional", defaultVisibility: "private", allowUserControl: true, }, location: "optional", // Shorthand: optional with public visibility, user can control }, },};Field configuration options:
requirement - "required", "optional", or "disabled"defaultVisibility - "public", "members-only", or "private" (default: "public")allowUserControl - Whether users can change the field’s visibility (default: true)Shorthand: You can use a string value (e.g., "optional") which defaults to public visibility with user control enabled.
Visibility levels:
public - Visible to everyone, including non-authenticated usersmembers-only - Only visible to authenticated community membersprivate - Only visible to the user themselvesConfigure which actions appear on profile components (popup and page). Actions are automatically available based on enabled modules, or you can define custom actions.
Example in cohera.config.ts:
export default { userProfiles: { actions: { // Use built-in module actions message: cohera.chat.messageAction, follow: cohera.connections.followAction, invite: cohera.events.inviteAction,
// Disable an action message: false,
// Define custom action custom: { label: "Custom Action", icon: "custom-icon", // optional handler: async (userId) => { // Your custom logic here console.log(`Action triggered for user: ${userId}`); }, }, }, },};Available built-in actions:
cohera.chat.messageAction - Send a message (requires chat module)cohera.connections.followAction - Follow/unfollow user (requires connections module)cohera.events.inviteAction - Invite to event (requires events module)Configure your authentication endpoint in cohera.config.ts:
export default { userProfiles: { auth: { endpoint: "https://your-auth-service.com/verify", // Optional: Custom headers to send with verification requests headers: { "X-API-Key": process.env.AUTH_API_KEY, }, }, },};The cohera user-profiles backend will call your endpoint to verify user sessions. Your endpoint should return user data in this format:
{ userId: string; username: string; // Any additional fields you want to sync}