mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 07:09:07 +03:00
24 lines
667 B
TypeScript
24 lines
667 B
TypeScript
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
|
|
import { useRouter } from 'next/router'
|
|
import { useEffect } from 'react'
|
|
import { LOCAL_STORAGE_KEYS } from './constants'
|
|
|
|
export function useIsEmbedded() {
|
|
const router = useRouter()
|
|
|
|
const isEmbeddedQueryParam = router.query._embed === '' || Boolean(router.query._embed)
|
|
|
|
const [isEmbedded, setIsEmbedded] = useLocalStorageQuery(
|
|
LOCAL_STORAGE_KEYS.EMBEDDED_MODE,
|
|
isEmbeddedQueryParam
|
|
)
|
|
|
|
useEffect(() => {
|
|
if (!isEmbedded && isEmbeddedQueryParam) {
|
|
setIsEmbedded(isEmbeddedQueryParam)
|
|
}
|
|
}, [isEmbedded, isEmbeddedQueryParam, setIsEmbedded])
|
|
|
|
return isEmbedded
|
|
}
|