How to fix link preload warning in Next.js app? #49607
Replies: 103 comments 201 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.
-
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.
-
Beta Was this translation helpful? Give feedback.
-
Next have so many bugs( |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Like thlindustries i was trying a lot of ways without success /// src/app/specific-dashboard/layout.tsx
'use client'
import { Roboto } from 'next/font/google'
import { cn } from '@/utils/style'
const fontRobotoSans = Roboto({
weight: ['100', '300', '400', '500'],
style: ['normal', 'italic'],
subsets: ['latin'],
variable: '--font-roboto',
display: 'swap',
})
export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div className={cn('font-roboto-sans', fontRobotoSans.variable)}>
{children}
</div>
)
} My bug scenario was using font at page level. With layout works for both |
Beta Was this translation helpful? Give feedback.
-
The more you save your code , the more the number of warnings increases, like a beard. |
Beta Was this translation helpful? Give feedback.
-
2024 and still getting this. |
Beta Was this translation helpful? Give feedback.
-
I was getting this message in my console when i would start my server. Browserslist: caniuse-lite is outdated. Please run: Once i ran npx update-browserslist-db@latest and updated my browerslist the warnings went away. I had tried everything else in this thread to no avail. Hopefully this helps some of you. Cheers! |
Beta Was this translation helpful? Give feedback.
-
In my case middleware caused it.
then added this to prevent if my url doesn't have query strings, to simply go back to previous page to set query string
So solution was to remove middleware on the page that had query string |
Beta Was this translation helpful? Give feedback.
-
I get the same warning, but in relation to the Hero image at the top of the front page:
It is incorrect that the image is not used, as it is the main image on the front-page. Anyone seeing the same, i.e. the error on images? |
Beta Was this translation helpful? Give feedback.
-
For my case, i just removed "import React from 'react'" from the top of my page: |
Beta Was this translation helpful? Give feedback.
-
I followed all the suggestions provided by the developer, but unfortunately, I couldn't find a solution to fix my error. Problem in Text Form :- |
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