Closed gmwill934 closed 1 year ago
Is Next JS not supported?
I have the same issue right now. By curiosity, which version are you running ?
latest 2.4.0
Try this code
const Toaster = dynamic(
async () => {
const { Toaster } = await import("react-hot-toast");
return Toaster;
},
{
ssr: false,
}
);
thanks, that worked
thanks, i just did that. here's a copy-paste from the dkms repo:
'use client'
import dynamic from 'next/dynamic'
const Toaster = dynamic(
async () => {
const { Toaster: BaseToaster } = await import('react-hot-toast')
return BaseToaster
},
{
ssr: false,
}
)
export const GlobalProviders = ({
children,
}: {
children: React.ReactNode
}) => (
<>
<Toaster />
{children}
</>
)
import { Inter } from 'next/font/google'
import clsx from 'clsx'
import { GlobalProviders } from '@/app/providers'
import '@/app/styles/index.css'
const inter = Inter({ subsets: ['latin'] })
export const metadata = {
title: 'magic link using lucia auth',
description:
'a sample demo of magic link using lucia auth with drizzle & sqlite',
}
const RootLayout = ({ children }: { children: React.ReactNode }) => {
return (
<html lang="en">
<body
className={clsx(
inter.className,
'min-h-screen bg-gray-900 text-white p-4'
)}
>
<GlobalProviders>{children}</GlobalProviders>
</body>
</html>
)
}
export default RootLayout
Hey
Currently using Next JS 13.0.6 with the new app directory and keep getting this annoying error.
Did not expect server HTML to contain a <h1> in <div>.
I have added the
Toaster
component on my root layoutAm I missing something?
Thanks