How to fix link preload warning in Next.js app? #49607
Replies: 92 comments 194 replies
-
Any fix to this ?? I am also getting the same issue |
Beta Was this translation helpful? Give feedback.
-
Still dealing with the issue. |
Beta Was this translation helpful? Give feedback.
-
same issue here in next.js version 14.2.0 |
Beta Was this translation helpful? Give feedback.
-
This error is coming in production or not? |
Beta Was this translation helpful? Give feedback.
-
I'm having the same error and I'm only with Footer component :/ I'm not done with the whole website |
Beta Was this translation helpful? Give feedback.
-
This issue actually coming from the next/font/google component. According to the warning preloaded link must have the appropriate as property whether this is a style or script link. I hope the next.js team will provide the solution soon :) |
Beta Was this translation helpful? Give feedback.
-
I thought it was a font issue so I removed const inter = Inter({ subsets: ['latin'] }); But still same warning. I also noticed that I loads a bunch of duplicate stylesheets, each warning adds another stylesheet to frame(see image). There is no warning once deployed on Vercel though. |
Beta Was this translation helpful? Give feedback.
-
The warning is given by the preloading of CSS modules through the Link component. |
Beta Was this translation helpful? Give feedback.
-
same issue here in next.js version 13.4.3 |
Beta Was this translation helpful? Give feedback.
-
had the same issue, removed path alias import and the warning went away somehow. // import "@/globals.css"
import "../../globals.css" |
Beta Was this translation helpful? Give feedback.
-
I have got the same problem with Next v.13.4.1. It's "REALLY ANNOYING" for debugging in DevTool. The error in the the DevTool said that the link suppose to have "as" property in the CSS styles tag from the tag. But as we can see on my picture Next.js generate link Stylesheet but not include "as" property. There is the error. I have done as Documentation said to import CSS Module like this image but error still show up: Are this a bug from App Directory? Because when I use Page Directory before this error is not happened. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
If the preload warnings related to the next/font/google component are ruining your day, you can try the CSS variable approach to font handling as described in the section regarding Using Multiple Fonts in the NextJS Font Optimization docs. Worked for me. See the code examples under the paragraph that begins with Alternatively, you can create a CSS variable... |
Beta Was this translation helpful? Give feedback.
-
Still testing but it seems to have worked for me. 1- In the import { Inter } from "next/font/google";
export const inter = Inter({
subsets: ["latin"],
display: "swap",
}); In the "use client";
import "./global.css";
import AuthContext from "./lib/authContext";
// aqui eu importei a font que quero usar, inclusive com esse método posso usar utras fontes em outras partes da mesma forma
// here I imported the font I want to use, even with this method I can use other fonts in other parts in the same way
import { inter } from "@/app/styles/fonts";
export interface RootLayoutProps {
children: React.ReactNode;
}
export default function RootLayout({ children }: RootLayoutProps) {
return (
<html>
<body className={inter.className}> //normal use in className - uso normal no className
<AuthContext>{children}</AuthContext>
</body>
</html>
);
} Espero que ajude, pra mim está funcionando / I hope this helps, it's working for me |
Beta Was this translation helpful? Give feedback.
-
If you're loading a font like the code below, changing the // 🟡 cause warnings
<link rel="preload" href="https://font-url.woff" as="font" /> // ✅ works without warnings
<link rel="prefetch" href="https://font-url.woff" as="font" /> |
Beta Was this translation helpful? Give feedback.
-
This issue randomly appeared for me with the |
Beta Was this translation helpful? Give feedback.
-
Today I had the same issue, came here and read it's probably from a font problem. I noticed the warning when navigating in the pages through the navbar. Next 13.5.4 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
What version of next.js are you on? |
Beta Was this translation helpful? Give feedback.
-
I had a same issue but I solved it with a simple solution. |
Beta Was this translation helpful? Give feedback.
-
As much as I tried to remove this warning, and that's what I came to. If you use a font in a component that does not load when you visit your site, it gives this error. But if you use the font as a variable for css, the error will disappear. In my case, preload is still working. What have I done for myself: Add
|
Beta Was this translation helpful? Give feedback.
-
I had this same issue and mine was also in the build version, but adding prefetch={false} to my links worked Next version: 14.0.4 |
Beta Was this translation helpful? Give feedback.
-
I had similar problem with fonts:
I just removed unused font declarations. Before: import { Inter, Roboto, Sora } from 'next/font/google'
export const inter = Inter({
subsets: ['latin'],
display: 'swap',
variable: '--font-inter'
})
export const roboto = Roboto({
subsets: ['latin'],
display: 'swap',
variable: '--font-roboto',
weight: '500'
})
export const sora = Sora({
subsets: ['latin'],
display: 'swap',
variable: '--font-sora'
}) and after (I use only Inter font in my NextJS project): import { Inter, Roboto, Sora } from 'next/font/google'
export const inter = Inter({
subsets: ['latin'],
display: 'swap',
variable: '--font-inter'
}) It was acording to the official doccumentation (using multiple fonts in NextJS Vercel Project): |
Beta Was this translation helpful? Give feedback.
-
I see the same issue The most interesting when you go to the - https://hot-delivery.vercel.app/ When you go to - https://nicitaa.com |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Importing
|
Beta Was this translation helpful? Give feedback.
-
Still having the issue, using Tailwind, custom font and google font import "./globals.css";
import type { Metadata } from "next";
import { Poppins } from "next/font/google";
import localFont from "next/font/local";
import { Header } from "@modules/ui/header/Header";
import { Footer } from "@modules/ui/footer/Footer";
const spartan = localFont({
display: "swap",
variable: "--font-spartan",
src: [
{
path: "./Spartan-Bold.ttf",
weight: "700",
},
{
path: "./Spartan-Medium.ttf",
weight: "500",
},
],
});
const poppins = Poppins({
subsets: ["latin"],
display: "swap",
weight: ["300", "500"],
variable: "--font-poppins",
});
export const metadata: Metadata = {
title: "",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="fr" className={`${spartan.variable} ${poppins.variable}`}>
<body className="flex min-h-screen flex-col font-sans">
<Header />
{children}
<Footer />
</body>
</html>
);
} After some second i got the warning in the console |
Beta Was this translation helpful? Give feedback.
-
I have the same issue, however, mine is with Google Adsense. Has anyone been able to resolve this with Google AdSense?
|
Beta Was this translation helpful? Give feedback.
-
Any fix to this? im facing the same problem in Next 14.2.3 |
Beta Was this translation helpful? Give feedback.
-
Summary
I am developing a Next.js app with version 13.4 and I am getting this warning in the console:
The resource <URL> was preloaded using link preload but not used within a few seconds from the window’s load event. Please make sure it has an appropriate as value and it is preloaded intentionally.
The number of the error is increasing.
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions