#router in Next13 Rootlayout

4 messages · Page 1 of 1 (latest)

spring axleBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

crimson orbit
#

is it good practice to do something like this in my RootLayout:'use client'
import { Inter, Lexend } from 'next/font/google'
import clsx from 'clsx'
import '@/styles/tailwind.css'
import AuthLayout from '@/components/AuthLayout'
// export const metadata = {
// title: {
// template: '%s - PartSoft',
// default: 'PartSoft - Efficient Truck Parts Ordering for Shops',
// },
// description:
// 'Finding the right truck parts can be cumbersome. PartSoft streamlines the process, ensuring shops get what they need quickly and accurately.',
// }

const inter = Inter({
subsets: ['latin'],
display: 'swap',
variable: '--font-inter',
})

const lexend = Lexend({
subsets: ['latin'],
display: 'swap',
variable: '--font-lexend',
})

export default function RootLayout({ children }) {
const pathname = window.location.pathname

if (pathname.startsWith('/dashboard')) {
return <AuthLayout>{children}</AuthLayout>
}

return (
<html
lang="en"
className={clsx(
'h-full scroll-smooth bg-white antialiased',
inter.variable,
lexend.variable,
)}
>
<body className="flex h-full flex-col">{children}</body>
</html>
)
}

#

is it good practice to do something like this in my RootLayout:```'use client'
import { Inter, Lexend } from 'next/font/google'
import clsx from 'clsx'
import '@/styles/tailwind.css'
import AuthLayout from '@/components/AuthLayout'
// export const metadata = {
// title: {
// template: '%s - PartSoft',
// default: 'PartSoft - Efficient Truck Parts Ordering for Shops',
// },
// description:
// 'Finding the right truck parts can be cumbersome. PartSoft streamlines the process, ensuring shops get what they need quickly and accurately.',
// }

const inter = Inter({
subsets: ['latin'],
display: 'swap',
variable: '--font-inter',
})

const lexend = Lexend({
subsets: ['latin'],
display: 'swap',
variable: '--font-lexend',
})

export default function RootLayout({ children }) {
const pathname = window.location.pathname

if (pathname.startsWith('/dashboard')) {
return <AuthLayout>{children}</AuthLayout>
}

return (
<html
lang="en"
className={clsx(
'h-full scroll-smooth bg-white antialiased',
inter.variable,
lexend.variable,
)}
>
<body className="flex h-full flex-col">{children}</body>
</html>
)
}```

#

I'm conditionally using the AuthLayout for those pages, and the regular layout if not on those pages. What's the best practice here?