A zero-dependency SMART on FHIR standalone-launch demo app. One command starts both the app and an in-process mock EHR, so the complete OAuth2 + PKCE flow runs offline: authorize redirect, state validation, code exchange, patient-context FHIR calls, and a rendered clinical summary.
- SMART standalone launch against any R4 server with SMART discovery
(
.well-known/smart-configuration) - PKCE (RFC 7636, S256) on every authorization code, verified end to end
stateparameter validation that blocks login CSRF- Authorization codes are single-use; replays are rejected
- Tokens live in memory only, sessions in an HttpOnly cookie, nothing logged
- SMART v2 scopes (
patient/Patient.rs,patient/Observation.rs, ...) - Real error states: cancelled launch, failed patient fetch, unknown routes
Requires Node.js 23.6+. No dependencies, no build step.
node src/app.ts
# smart-launch running in mock mode at http://127.0.0.1:8410
# mock EHR (FHIR ISS): http://127.0.0.1:<ephemeral>/mock/fhirOpen the printed URL, click "Launch against the EHR", and walk the whole flow.
export SMART_MODE=real
export SMART_ISS=https://your-fhir-server/r4
export SMART_CLIENT_ID=my-client
export SMART_CLIENT_SECRET=... # confidential clients only
export SMART_REDIRECT_URI=http://localhost:8410/callback
node src/app.tsWorks with any server that supports standalone launch and PKCE (public HAPI FHIR sandboxes, SMART health-it launch environments, hospital test environments).
node --testSix end-to-end tests drive real HTTP sockets against the mock EHR, including the negative paths (forged state, code replay, no-session access).
Most SMART samples hide the flow inside a SDK. This one spells it out with
plain fetch and node:http, which makes it a readable reference for
implementing SMART launches against hospital FHIR endpoints, and a sandbox
for testing the edge cases that matter in clinical settings.
MIT