Next.js Discord

Discord Forum

Favicon

Unanswered
Griffon Bleu de Gascogne posted this in #help-forum
Open in Discord
Griffon Bleu de GascogneOP
Hello, someone know why my icon won t change ?

import type { Metadata } from "next";
import "./globals.css";
import { ThemeProvider } from "@/components/theme-provider";
import { aquire, cn } from "@/lib/utils";
import { ToastContainer } from "react-toastify";
import { webmetadata } from "@/lib/constants";
import 'react-toastify/dist/ReactToastify.css';

export const metadata: Metadata = webmetadata

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {
  return (
    <html lang="en" suppressHydrationWarning>
        <head>
          <link rel="icon" href="/icon?<generated>" type="image/png" sizes="32x32" />
        </head>
        <body className={cn(aquire.className, "bg-black")}>
          <ThemeProvider
            attribute="class"
            defaultTheme="black"
            enableSystem
            disableTransitionOnChange
          >
            <ToastContainer />
            {children}
          </ThemeProvider>
        </body>
      </html>
  );
}

40 Replies

Griffon Bleu de GascogneOP
import { ImageResponse } from "next/og";

export const runtime = "edge";
export const size = {
    width: 32,
    height: 32,
};

export const contentType = "image/png";

export default function Icon() {
    return new ImageResponse(
        <div
            style={{
                fontSize: 24,
                background: "white",
                width: "100%",
                height: "100%",
                display: "flex",
                justifyContent: "center",
                alignItems: "center",
                color: "white",
            }}
        ></div>
    ),
    {...size}
}
if generate it won t work i have favicon.ico
I think you just put your favicon under app/favicon.ico or public/favicon.ico and next.js will automatically generate it, no need to do it manually in layout IIRC
restart the server
and do hard reload
Griffon Bleu de GascogneOP
@averydelusionalperson and do hard reload
Griffon Bleu de GascogneOP
how ?
clear data
in my f12 ?
it's cmd + shift + r on mac ig
it's safari right?
Griffon Bleu de GascogneOP
i try and i try in private nothing change
you removed the link from layout page right?
Griffon Bleu de GascogneOP
remove either svg or .ico
don't keep both
Griffon Bleu de GascogneOP
the best between ico and svg ?
I use .ico
Griffon Bleu de GascogneOP
no changes
could you show your favicon file
Griffon Bleu de GascogneOP
restart the server, and open the website on incognito
Griffon Bleu de GascogneOP
okay
no changes
how i can use svg ?
just delete .ico one
and keep .svg
ig
Griffon Bleu de GascogneOP
okay
Griffon Bleu de GascogneOP
thx
i will try
sure
Griffon Bleu de GascogneOP
later
🕺