wasp/web/versioned_docs/version-0.12.0/auth/entities/_get-username.md
2024-02-27 09:26:16 +01:00

976 B

The getUsername helper returns the user's username or null if the user doesn't have a username auth identity.

import { getUsername } from 'wasp/auth'

const MainPage = ({ user }) => {
  const username = getUsername(user)
  // ...
}
import { getUsername } from 'wasp/auth'

export const createTask = async (args, context) => {
  const username = getUsername(context.user)
  // ...
}
import { getUsername, AuthUser } from 'wasp/auth'

const MainPage = ({ user }: { user: AuthUser }) => {
  const username = getUsername(user)
  // ...
}
import { getUsername } from 'wasp/auth'

export const createTask: CreateTask<...>  = async (args, context) => {
  const username = getUsername(context.user)
  // ...
}