Invite User to Organization Component - PropelAuth Docs

Invite User to Organization Component

PropelAuth's Invite User to Organization component allows you to customize the flow around a user inviting another user to their organization in your app.

Invite User to Organization

Invite User


Shadcn Installation

Install this component from our shadcn registry.

npx shadcn@latest add https://components.propelauth.com/r/invite-user-to-organization.json

Reference APIs

These are the APIs that are used by the above component. You can use these APIs directly in your own code.

inviteUserToOrg

Sends an invitation to a user to join an organization.

Arguments

Response Functions

The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.

Request

const { inviteUserToOrg } = useAuthFrontendApis()

const response = await inviteUserToOrg({
    org_id: '1189c444-8a2d-4c41-8b4b-ae43ce79a492',
    email: 'test@example.com',
    role: 'Admin',
    // if using multi-role support
    additional_roles: [
        "Member"
    ]
})
response.handle({
    success: () => {
        console.log('User invited')
    },
    badRequest(error) {
        for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
            console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
        }
    },
    noInvitePermission(error) {
        console.error('No invite permission', error)
    },
    orgNotFound(error) {
        console.error('Org not found', error)
    },
    orgsNotEnabled(error) {
        console.error('Org not enabled', error)
    },
    userAlreadyInOrg(error) {
        console.error('User already in org', error)
    },
    orgMaxUsersLimitExceeded(error) {
        console.error('Org max users limit exceeded', error)
    },
    unexpectedOrUnhandled(error) {
        console.error('Unexpected or unhandled error', error)
    },
})

Successful Response

{}