Embed NXT Content into your App
The best way to show NXT content in a mobile app is a WebView. You can use the same embed code as on your website, or load a URL that already embeds the content.
App/WebView origin check (must-read for app integrations)
The embed only shows content if the request origin matches your allowed embed domains (in NXT: Settings → General → Allowed embed domains).
- What we check: the request origin (the WebView’s
window.location.origin: scheme + host [+ port]). Forhttps://pages we compare its domain, for any other scheme the scheme itself. - Typical app cases:
1) Load a normal
https://URL in a WebView 2) Load local HTML inside the WebView
Android specifics
- Hosted page: use
webView.loadUrl("https://your-domain/..."). Make sure that domain is in the allowed embed domains. - Local HTML:
loadDataWithBaseURL(baseUrl, html, ...)withbaseUrlset to anhttps://address on an allowed domain; requests use that origin.- Or use
WebViewAssetLoaderwithsetDomainto serve local assets under anhttps://host. Add that host’s domain to the allowed embed domains.
- If your local pages run under a custom scheme (for example
myapp://), list the scheme asmyapp:.
iOS specifics
- Hosted page: use
WKWebViewand load anhttps://URL; add that domain to the allowed embed domains. - Local HTML:
loadHTMLString(embedHtml, baseURL: httpsBaseUrl)works ifhttpsBaseUrlpoints to an allowed domain. The WebView uses thebaseURLorigin for requests. - With a custom URL scheme handler (for example
myapp://), list the scheme asmyapp:.
Don’t load the embed from file://: depending on the WebView, such pages have a null origin, which is always blocked, or a file: origin.
Quick troubleshooting
- In the WebView dev tools, run
window.location.originand compare it to your allowed embed domains. - Ensure you are loading over
https://or your listed app scheme (notfile://). - Check redirects: did the page land on a different host than expected?
- If the element shows “This content is not enabled for this website”, the origin is not allowed yet.
Storage in WebViews
The embed works without browser storage. If the WebView keeps no storage, it can’t remember a reader across app starts: for example, a poll the reader answered shows as unanswered again. What the embed stores, and when, is described in Data Protection.