License: Apache 2.0 · SDK package · Official SDK documentation
Reference frontend apps for embedding Tableau Next dashboards, metrics, visualizations, and AnalyticsAgent with Analytics Embedding SDK 2.0. The same scenarios are implemented in React, Vanilla JavaScript, and Angular.
This repository's current scope is frontend integration plus a local development utility for generating test credentials. A production authentication service is intentionally out of scope.
| Stack | Source | API style |
|---|---|---|
| React 19 + Vite 8 + TypeScript | examples/react-vite/ | SDK classes, hooks, lazy route |
| Vanilla JavaScript | examples/vanilla-js/ | CDN module, HTML custom elements, no build step |
| Angular 22 | examples/angular/ | SDK classes, signals, dependency injection |
Every example includes:
- a Showcase view with a dashboard, metric, and visualization;
- an AnalyticsAgent view;
- one-time SDK initialization;
AUTH_REDIRECTrecovery withretryOrAddOrgs;- runtime error handling and component cleanup; and
- an in-app demo form that keeps the credential in memory only.
Reloading or resetting an example discards the credential and requires a fresh frontdoor URL.
Complete the Salesforce prerequisites first. In particular, you need:
- an appropriately licensed Salesforce org with Tableau Next enabled;
- access to each embedded analytics asset;
- the example origin in the org's CORS allowlist and embedding/trusted-domain settings;
- a supported browser configured to allow the cookies required by the embed;
- an ID or API name for at least one dashboard, metric, visualization, or AnalyticsAgent; and
- a freshly generated frontdoor URL from an approved OAuth/UI Bridge flow (the included local utility can perform this flow for test orgs).
Use a sandbox and a least-privileged user for these examples. Node.js 22.12 or newer is recommended for the repository's current tooling.
Run an example, then enter at least one dashboard, metric, visualization, or Analytics Agent ID or API name in the setup form.
cd examples/react-vite
npm ci
npm run devOpen http://localhost:8500.
cd examples/vanilla-js
npx --yes serve@14.2.6 . -l 8500Open http://localhost:8500. The SDK loads directly from the pinned CDN URL
in js/sdk-cdn.js; installing packages is only necessary for repository
linting, typechecking, and tests.
cd examples/angular
npm ci
npm startOpen http://localhost:8500.
The SDK accepts a frontdoor URL as authCredential. For these local examples,
paste a fresh URL into the setup form. It is passed directly to
initializeAnalyticsSdk, never written to web storage, and removed from the
visible form immediately. See the demo authentication guide.
For a real application, use a backend OAuth 2.0 Web Server Flow and generate the browser credential through Salesforce UI Bridge. Do not ask users to copy session cookies and do not place refresh tokens or client secrets in frontend code.
The zero-dependency frontdoor URL utility runs the OAuth Web Server Flow with PKCE and calls UI Bridge from a localhost process:
cd tools/frontdoor-url
export SF_CLIENT_ID='your-external-client-app-consumer-key'
export SF_LOGIN_URL='https://your-domain.my.salesforce.com'
npm startYour External Client App must allow http://localhost:1717/callback and the
web scope. The utility displays the one-time URL in the callback page; it
does not print or persist the access token or frontdoor URL. See the
utility setup guide before running it.
- Collect
orgUrland a freshauthCredential. - Call
initializeAnalyticsSdkonce for the document. - Render assets only after
Status.SUCCESS. - If an org reports
OrgStates.AUTH_REDIRECT, open the returned verification URL and inspect the result ofretryOrAddOrgs. - Subscribe to
EventName.ERRORand remove SDK elements during framework cleanup.
The examples deliberately validate only that orgUrl is an HTTPS URL. Valid
Salesforce org hostnames vary, and the SDK/org response is the authority on
whether initialization is allowed.
analytics-embedding-example-apps-and-auth/
├── docs/
│ ├── prerequisites.md
│ └── how-to-get-frontdoor-url.md
├── examples/
│ ├── react-vite/
│ ├── vanilla-js/
│ └── angular/
├── tools/
│ └── frontdoor-url/ # Local OAuth + UI Bridge helper
└── .github/workflows/
These are reference examples, not a supported product. Report defects through GitHub Issues. For security reports, follow SECURITY.md and do not open a public issue.
See CONTRIBUTING.md and CODE_OF_CONDUCT.md. Licensed under Apache 2.0; see LICENSE.txt. Third-party dependencies, including the Analytics Embedding SDK, remain subject to their respective license terms.