You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
375 B
JavaScript

import { useEffect, useState } from 'preact/hooks'
export const useUser = () => {
const [username, setUsername] = useState(null)
useEffect(async () => {
const res = await fetch(`/api/current-user`, {
credentials: 'include',
})
const username = await res.json()
setUsername(username)
}, [])
return { username }
}