Skip to main content

Widget installation

This page describes the supported way to embed the widget in production: versioned CDN with Subresource Integrity (SRI), Content-Security-Policy, and a pinned-version fallback when @latest moves.

Prerequisites

  • A Widget Token (header X-Widget-Token). If you don't have one yet, follow Authentication → Widget Token.
  • A container in your template, typically a <div id="neuroon-search"></div>.
  • Permission to add a <script> in <head> or before </body>.

Available versions

Loading versions…

Base snippet

index.html
<div id="neuroon-search"></div>
<script
  src="https://cdn.neuroon.ai/widget/widget.js"
  data-token="YOUR_WIDGET_TOKEN"
  data-container="#neuroon-search"
  data-theme="auto"
  data-locale="es"
></script>
<div id="neuroon-search"></div>
<script
src="https://cdn.neuroon.ai/widget@0.9.10/widget.js"
data-token="WIDGET_TOKEN_HERE"
data-container="#neuroon-search"
data-theme="auto"
data-locale="es"
data-api-url="https://api.neuroon.ai"
async
></script>

The script auto-initializes: it detects data-token, mounts the Shadow DOM in the data-container (defaults to #neuroon-search if omitted) and renders the UI. You don't have to call any extra JavaScript API for the standard flow.

Subresource Integrity (SRI)

Each widget release publishes an SRI manifest with the SHA-384 hash of the bundle:

https://cdn.neuroon.ai/widget@0.9.10/sri-manifest.json

The global SRI manifest for the latest version is at https://cdn.neuroon.ai/sri-manifest.json and the published-version index at https://cdn.neuroon.ai/versions.json.

Add it to the <script> so the browser rejects any CDN tampering:

<script
src="https://cdn.neuroon.ai/widget@0.9.10/widget.js"
integrity="sha384-AbCdEf123…"
crossorigin="anonymous"
data-token="WIDGET_TOKEN_HERE"
data-container="#neuroon-search"
async
></script>

data-* attributes

The parser lives in widget/src/core/config.ts (parseDataAttributes). Only these attributes are read — anything else is ignored.

AttributeRequiredValue
data-tokenyesWidget Token (opaque string issued by Neuroon).
data-containernoCSS selector of the container. Defaults to #neuroon-search.
data-themenoauto (default), light, dark.
data-localenoOne of the 9 supported codes. Default es.
data-api-urlnoAPI base URL override. Default https://api.neuroon.ai.
data-primary-colornoHex/rgb of the primary color (legacy shortcut; prefer StyleOverrides).
data-placeholdernoEmpty-input text.
data-suggestionsnofalse disables the suggestions dropdown.
data-filtersnofalse disables filters and the drawer.

Content-Security-Policy

If your host enforces strict CSP, the widget needs these directives:

script-src 'self' https://cdn.neuroon.ai;
connect-src 'self' https://api.neuroon.ai https://browser-intake-datadoghq.eu;
img-src 'self' data: https:;
font-src 'self' https://rsms.me;
style-src 'self' 'unsafe-inline';
  • connect-src — the widget calls the API and, when optional monitoring is enabled, reports to browser-intake-datadoghq.eu.
  • font-src https://rsms.me — the widget preconnects and loads the Inter family from rsms.me.
  • style-src 'unsafe-inline' — required because the widget injects <style> inside the Shadow DOM. The Shadow DOM isolates that stylesheet from the host document.

Variants per environment

EnvironmentCDNAPI
Productionhttps://cdn.neuroon.ai/widget@0.9.10/widget.jshttps://api.neuroon.ai
Developmentsame CDN, same versionshttps://dev-api.neuroon.ai

To point at Development, set data-api-url="https://dev-api.neuroon.ai". The widget bundle is the same.

Programmatic initialization (optional)

Auto-init covers most integrations. If you need fine-grained control (lazy-load, multiple instances, dynamic server-side configuration), use the JavaScript API:

const widget = window.NeuroonWidget.init({
container: '#neuroon-search',
token: 'WIDGET_TOKEN_HERE',
apiUrl: 'https://api.neuroon.ai',
theme: 'auto',
locale: 'es',
})

// Methods available on the instance
widget.setTheme('dark')
widget.setStyles({ primary: '#06b6d4' })
widget.destroy()

Further reading