e93a35bb26
Just tried to update to 14 but `next/third-parties` looks like it's still expecting us to be on Next 13 ``` Error: npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: shop-next@0.1.1 npm ERR! Found: next@14.0.0 npm ERR! node_modules/next npm ERR! next@"^14.0.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer next@"^13.0.0" from @next/third-parties@14.0.0 npm ERR! node_modules/@next/third-parties npm ERR! @next/third-parties@"^14.0.0" from the root project npm ERR! npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this command with --force or --legacy-peer-deps npm ERR! to accept an incorrect (and potentially broken) dependency resolution. npm ERR! npm ERR! npm ERR! For a full report see: npm ERR! /Users/XXXXXXXX/.npm/_logs/2023-10-26T17_27_38_736Z-eresolve-report.txt ``` |
||
---|---|---|
.. | ||
src | ||
package.json | ||
README.md | ||
tsconfig.json |
Experimental @next/third-parties
@next/third-parties
is a collection of components and utilities that can be used to efficiently load third-party libraries into your Next.js application.
Note:
@next/third-parties
is still experimental and under active development.
Usage
Google Third-Parties
YouTube Embed
The YouTubeEmbed
component is used to load and display a YouTube embed. This component loads faster by using lite-youtube-embed under the hood.
import { YouTubeEmbed } from '@next/third-parties/google'
export default function Page() {
return <YouTubeEmbed videoid="ogfYd705cRs" height={400} />
}
Google Maps Embed
The GoogleMapsEmbed
component can be used to add a Google Maps Embed to your page. By default, it uses the loading
attribute to lazy-load below the fold.
import { GoogleMapsEmbed } from '@next/third-parties/google'
export default function Page() {
return (
<GoogleMapsEmbed
apiKey="XYZ"
height={200}
width="100%"
mode="place"
q="Brooklyn+Bridge,New+York,NY"
/>
)
}
To get a better idea of how these components work, take a look at this demo.