import {useRouter} from 'next/router' export default function useIsAdminPage(){ const {asPath: fullpath} = useRouter() const withoutQuery = fullpath.split('?')[0] const adminRoutes = new RegExp('^/admin(/.*|$)') return withoutQuery.match(adminRoutes) }