rspress-plugin-third-parties
This plugin provides components for YouTube, Twitter/X, and Google Maps, integrations for Google Analytics and Google Tag Manager, and a Script component for controlling when scripts load.
This is a community-maintained integration.
- Documentation and demos, maintained by the plugin author.
- Plugin README for all component options.
Installation
Global analytics
To add Google Analytics to all pages, register the plugin in rspress.config.ts and replace G-XXXXXXXXXX with your GA4 measurement ID:
For client-side navigation tracking, configure GA4 single-page application measurement.
Components
Import components into an MDX page or custom theme. The YouTube and Tweet examples below include live previews alongside their source code.
<YouTubeEmbed />
Shows a video thumbnail and loads the YouTube player when you click play.
<TweetEmbed />
Embeds a Twitter/X post and follows the site's light or dark theme.
<GoogleMapsEmbed />
Embeds a Google Map. Replace the placeholder with your Google Maps Embed API key to use this example.
<Script />
Loads external or inline scripts and deduplicates external script loads across page transitions. The default strategy is afterInteractive; use lazyOnload to wait until the page has loaded and the browser is idle.
<GoogleTagManager />
Add Google Tag Manager to your custom theme layout.
<GoogleAnalytics />
Add GA4 to your custom theme layout. Skip this component if you already registered the same measurement ID with the global plugin.
After configuring Google Analytics, use sendGAEvent in an event handler to send custom events: