In order to render the server url on link field in Next.jsGraphQL, return the jsonValue
from GraphQL as below.
query ContentCardQuery($datasource: String!) {
datasource: item(path: $datasource, language: "en") {
id
name
... on About {
title {
value
}
link {
jsonValue
}
}
}
}
Thereafter you can refer Link
component from Next.js in frontendThis will contains the server link as well as enlisted below.
import {
Link
} from '@sitecore-jss/sitecore-jss-nextjs';
// Refer the link field jsonValue from GraphQL
<Link
field={props.link.jsonValue}
/>
Using above way,Note: Make sure you can successfully edit and render links in experience editor as wellset the alwaysIncludeServerUrl
setting as it displaystrue
for the link provider specified on the website as well.
Hope this helps!!! Let me know in case you have any doubts.