Advanced Topics
Get Session Data

Get data of current session


If you want to access the current user's data, e.g., to show the user's first name, you can either use the useSession hook or an async helper.

useSession hook

import { useSession } from "@roq/ui-react";
const { session, status } = useSession();
const firstName = session.user.firstName;

async helper

import { getSession } from "@roq/ui-react";
const user = await getSession();
const firstName = user.session.user.firstName;


You can access the current user's data using this request handler:

import { getServerSession } from "@roq/nextjs";
async function handler(req: NextApiRequest, res: NextApiResponse) {
  const session = getServerSession(req);
  const user = session.user;