Learn how to integrate Locadapt with popular frontend frameworks like React, Svelte, Next.js, and Vue.
data-start-hidden
and a loading indicator to prevent flashes of un-translated content. See Next.js for an example or refer to the Custom Attributes section below.
public/index.html
file:
index.html
or app.html
file:
data-ssr-defer
(and possibly defer
if the compiler complains) attributes to the script tag:
pages/_document.js
or app/layout.tsx
file. This example also shows the use of data-start-hidden
and a loading indicator to prevent flashes of un-translated content.
index.html
file:
data-ssr-defer
attribute:
Next.js
section above — copied directly from Locadapt’s site! (Our is particularly complex due to running both SSR and non-SSR versions of Locadapt, as well as an MDX blog.)
data-ssr-defer
: Defers Locadapt initialization to the client. Use this for SSR applications. You may otherwise see hydration issues if the server returns translated content, but client generates un-translated content.data-link-prevent-default
: Makes Locadapt handle link clicks internally for smooth SPA transitions. If link rewriting is not working, set this.data-start-hidden
: Initially hides page content, revealing it after Locadapt finishes initializing. Useful for preventing flashes of untranslated content in complex applications not on the subdomain
schema. We recommend setting a #locadapt-optional-loading-indicator
in your HTML to show while Locadapt initializes. If you use this, you must also wrap your page content in a div
with id="custom-base-content"
, and set its style
to display: none;
(it will be unset after Locadapt initializes).data-start-hidden
and a loading spinner. By default, this spinner will only be around for a max of 1-2 seconds, as if new translations are required, these will be requested once the spinner is removed.
<head>
: Add the Locadapt script in the <head>
of your HTML document.data-ssr-defer
attribute for (and only for) SSR applications.data-link-prevent-default
to handle navigation.support_dynamic_content
is enabled in your project settings.window.locadapt.updateContent();
to translate the content when it has been loaded.