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.
Quickstart — React (recommended)
If you’re using React, use<EdpireAssessmentPlayer> from @edpire/sdk/react. It handles token fetching, mounting, and cleanup automatically.
Server — create the token endpoint:
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):- Next.js App Router
- Express / Vite dev server
- Manual (any runtime)
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.
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.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 receiveORIGIN_NOT_ALLOWED in onError:
- Go to edpire.com → Integrations → Security tab → Allowed Embed Origins
- Add every origin your app runs on:
http://localhost:3000(Next.js dev)http://localhost:5173(Vite dev)https://yourapp.com(production)
- Save and reload — the player should appear immediately.
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
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: