Skip to main content
The Embedded Player renders Edpire’s complete assessment UI inside a container on your page. The SDK fetches the assessment, handles every interaction, grades the submission, and shows per-question feedback — all from one function call. The learner never leaves your app.
Why a server endpoint? You can’t call Edpire directly from the browser — your API key would be visible in the JavaScript bundle for anyone to read. The token endpoint lets your server verify the learner (from your session), mint a short-lived single-use token, and send only that to the browser. The browser never touches your API key.
Fastest start: scaffold a ready-to-run example instead of wiring this by hand.
Both examples ship inside the @edpire/sdk npm package — no separate repo needed. Each has a README with next steps.
If you’re using React, use <EdpireAssessmentPlayer> from @edpire/sdk/react. It handles token fetching, mounting, and cleanup automatically. Server — create the token endpoint:
Browser — render the player:
That’s the entire integration. The component handles token fetching, useRef / useEffect lifecycle, and StrictMode double-invoke cleanup for you. See EdpireAssessmentPlayerProps for the full prop list.

Quickstart — vanilla JS / other frameworks

For non-React setups (Vue, Svelte, Solid, plain JS): 1. Mint a token (server endpoint):
Security — never trust the client for the learner ID. The token endpoint should resolve the learner from your server session (getServerSession(), a cookie lookup, a verified JWT). If you read userId from the request body, anyone can mint tokens for other learners. createEdpireTokenHandler enforces this via the resolveLearner callback.
The token expires after 2 hours and is consumed when the learner submits. Mint a fresh one each time the learner opens the assessment; minting does not invalidate a token already in use, so a learner with the assessment open in another tab is unaffected.
2. Mount the player (browser):

Container sizing

The player fills its container. You are responsible for sizing the container. A container with no explicit height (or one constrained by centering utilities) collapses to zero and hides the player.
If you’re using a CSS framework that applies global centering or max-width constraints to #root or body (common in Vite and CRA templates), remove or override those rules for the player container. A width: 1126px; margin: auto wrapper will visually cut off the player and may break layout in RTL mode.

Environment variables


Allowed Origins

The embed player is origin-scoped — it only loads from domains you explicitly allow. If you see a blank player or receive ORIGIN_NOT_ALLOWED in onError:
  1. Go to edpire.com → Integrations → Security tab → Allowed Embed Origins
  2. Add every origin your app runs on:
    • http://localhost:3000 (Next.js dev)
    • http://localhost:5173 (Vite dev)
    • https://yourapp.com (production)
  3. Save and reload — the player should appear immediately.
Not sure if it’s an origin error? Add a temporary onError handler to log the code:
ORIGIN_NOT_ALLOWED means the allow-list is missing your domain.

MountOptions

mediaHandler

Required only if your assessment contains OpenResponse questions with file-upload or audio/video recording. Without it those question types silently fail to submit.
upload receives (file, type) and must resolve to { url, mimeType? }. There is no progress callback — if you want a progress bar, track it in your own upload code and render it outside the player.

Return value — EmbedInstance

Call unmount() to tear down the player and clean up. It’s safe to call from inside onComplete — the SDK defers the actual React unmount so it never fires mid-render.

EmbedResult

Passed to onComplete after a successful submission.
If awaiting_manual_grading is true, the visible score is provisional — open-response answers still need a teacher. Listen for the submission.graded webhook to learn the final score.

EmbedError

Passed to onError.

CDN / no-bundler

For a plain <script> tag (no bundler), use the UMD build’s EdpireSDK global:
The UMD build is served straight from npm by jsDelivr (and unpkg) — no CDN of your own to run. Pin an exact version (@0.6.5) for production; @latest is fine for prototyping. The SDK is pre-1.0, so minor releases can contain breaking changes.
This is the same pattern used for Mobile & WebView integration.