I've been working on my Next JS app with React.
Basically I have the ff codes on my index.js file:
import Document, { Html, Head, Main, NextScript } from "next/document";
class MyDocument extends Document {
render() {
return (
<Html lang="en">
<Head>
<meta charset="UTF-8" />
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0"
crossorigin="anonymous"
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}
export default MyDocument;
As you can see here I've added a Bootstrap CDN and a meta information.
And then inside my _app.js I've added my meta viewport:
import Head from "next/head";
function MyApp() {
return (
<>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</Head>
</>
);
}
export default MyApp;
When I run npm run dev, I got the error here:
Warning: Invalid DOM property `charset`. Did you mean `charSet`?
at meta
at head
at Head (C:\Users\D\Desktop\multiblog\frontend\.next\server\pages\_document.js:705:5)
Am I doing this right? separating my meta information and link tag to my index.js?
What I want is to load all of my meta tags once the pages loads first?
Any idea?