Client Side Functions
Functions in this section are only usable as Remix actions.
Logout
A Remix action that logs the user out of their current session.
LogoutButton.tsx
import { Form } from '@remix-run/react'
export default function LogoutButton() {
<Form method="post" action="/api/auth/logout">
<button type="submit">Logout</button>
</Form>
}
Set Active Org
A Remix action that sets the user's Active Org. This is useful to identify which org a user is currently interacting with. See Active Org documentation for more information.
import { useFetcher } from '@remix-run/react'
export default function SetActiveOrg() {
const fetcher = useFetcher()
const setActiveOrg = (orgId: string) => {
fetcher.submit(
{ active_org_id: orgId },
{
method: "post",
encType: "application/json",
action: "/api/auth/set-active-org",
navigate: false,
}
);
};
const orgId = // get orgId from somewhere
setActiveOrg(orgId)
}