renderMetaTags() returns JSX elements. This is normally the one you’d use if you’re writing Next/React code, since you can put it inside the JSX code directly (like in Next’s <Head> component, which is not the same as the HTML <head> tag): Components: <Head> | Next.js
For example:
export default function Head() {
return (
<>
{ renderMetaTags([{tag: 'title', content: 'This is my title'}]) }
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<link rel="icon" href="/images/favicon.ico"/>
</>
);
}
Will you give the expected tab title:
But if you use renderMetaTagsToString(), it will literally output that string onto the page, which is almost never what you want:
The latter might be useful if you were, say, doing string manipulation and editing raw HTML templates (instead of JSX). In that case it might be useful to have the raw strings instead of JSX elements. But for the most part in a Next project you probably won’t need it.