Well... i don't know if this is going to work, but this is what I'm going to try:
// Add useEffect to your existing imports
import { Suspense, useState, useEffect } from 'react';
// Add this effect right after your existing useEffect hooks
export function App(): JSX.Element | null {
const medplum = useMedplum();
// Add token refresh effect
useEffect(() => {
if (!medplum) return;
// Refresh token every 45 minutes (giving 15 min buffer before 1 hour expiration)
const refreshInterval = setInterval(() => {
medplum.refreshIfExpired(900); // 900 seconds (15 minutes) grace period
}, 45 * 60 * 1000);
return () => clearInterval(refreshInterval);
}, [medplum]);
// ... rest of your existing App component code
}