translation-widget npm package to add the JigsawStack Translation Widget to your React or Next.js application.
Create a Translation component
Create a new component file (e.g., Replace
components/Translation.tsx) that initializes the widget on the client side:"YOUR_PUBLIC_KEY_HERE" with your public key from the JigsawStack dashboard.The widget is loaded via a dynamic
import() inside useEffect, which ensures it only runs in the browser. This prevents SSR errors when rendering on the server where window is not available.Framework-specific guides
For detailed setup instructions tailored to your Next.js router version:Next.js App Router
For Next.js 13+ projects using the App Router with the
"use client" directive and dynamic script loading.Next.js Pages Router
For Next.js 12 and below projects using
_app.tsx and the Next.js Script component.