Development Guides
SDK
User Invites

User invites

Introduction

ROQ SDK for BaaS provides a comprehensive user invite solution to be used alongside authentication. The front-end SDK offers an API for user invitation that developers can use directly in their client-side applications.

The user invitation API is part of the ROQ Platform and it also generated by the @roq/cli tool on the client side for easy integration with whichever framework you use. On the client side the generated SDK are live by default in the /lib/roq folder.

The user invitation API can be accessed through the roqPlatform property of the ROQ client, that's the roqBrowserClient method. So to use it, we can import it like this:

import { roqBrowserClient } from '@/lib/roq/roq-client';

To use any user invitation API we can call it like this:

await roqBrowserClient.roqPlatform.someUserInvitationMethod()

Code examples

If we want to invite a user, then we should use the sendUserInvites(). This method accepts a userInvites object as a parameter and the important thing to note is that we can invites many users at once.

This example shows how to invite a user using the sendUserInvites() method:

import { roqBrowserClient } from '@/lib/roq/roq-client';
 
const tenantId = "tenant_id_here"
const roqUserId = "roq_user_id"
 
const sendInvitation = async () => {
    const status = await roqBrowserClient.roqPlatform.sendUserInvites({
        userInvites: {
            tenantId: tenantId,
            userInvites: [{
                createdByUserId: roqUserId,
                email: email,
                locale: "en-US"
            }]
        }
    })
}

You can get the tenant and current user ID from the session data. If you use Next.js, you can go directly here, where we explain how to get the information from the session data.

Frameworks integration

Read on how to add user invitation into the Next.js application.

For more about user invites, please refer to the user invites documentation section. It covers the user invitation process.