Server Mode
Server mode connects your site to a running Loco instance. Text nodes are discovered and registered in real-time, and translations are fetched from the server on demand.
Setup
<script src="https://your-loco-server.com/cdn/loco.js"></script>
<script>
Loco.init({
apiUrl: 'https://your-loco-server.com',
apiKey: 'YOUR_API_KEY'
});
// Apply a language (can be called anytime)
Loco.apply('fr');
</script>
How it works
loco.jsscans the DOM and extracts all translatable text nodes- Text nodes are sent to
POST /api/textnodesand appear in the dashboard as Pending - A
MutationObserverwatches for new DOM nodes and registers them automatically Loco.apply('fr')fetches approved translations fromGET /api/translations?lang=frand swaps text in the DOM
Getting the API key
The API key is printed on server startup. You can also find it in Dashboard → Settings.
Floatable language switcher
Loco.widget({ position: 'bottom-right' }); // 'bottom-left' | 'top-right' | 'top-left'
Dynamic content (SPAs)
The MutationObserver is active by default. Newly added DOM nodes are registered automatically with no extra code needed.
You can manually pause and resume scanning:
Loco.stopScan(); // pause observer
Loco.startScan(); // resume observer
Loco.rescan(); // force re-scan now
Security
All API routes except /api/project require the X-API-Key header. The loco.js client sends it automatically after Loco.init().