boogiecoco.
04/12/2023, 6:00 AMrahul1
04/12/2023, 5:11 PMuseMedplum hook just returns the MedplumClient object you create during app initialization, so you could always use that object directly instead of calling the hook
https://github.com/medplum/medplum-nextjs-demo/blob/main/pages/_app.tsx#L7-L16rahul1
04/12/2023, 5:14 PMrahul1
04/12/2023, 5:15 PMboogiecoco.
10/17/2023, 5:38 PMboogiecoco.
10/17/2023, 5:46 PMstartGoogleLogin `rahul1
10/17/2023, 6:13 PMgetAccessToken (https://www.medplum.com/docs/sdk/classes/MedplumClient#getaccesstoken) method to retrieve the token on the client. Iron session might be applicable here (https://github.com/vercel/next.js/tree/canary/examples/with-iron-session)
- You could then read the medplum token inside the getServerSideProps , and use setAccessToken (https://www.medplum.com/docs/sdk/classes/MedplumClient#setaccesstoken) for a client created inside the function to make the calls. You could also make raw fetch calls if creating the client becomes a performance bottlneckboogiecoco.
10/17/2023, 6:16 PMrahul1
10/17/2023, 8:31 PMboogiecoco.
10/17/2023, 9:55 PMboogiecoco.
10/17/2023, 10:00 PMconst medplum = new MedplumClient({
fetch: async (url: string, options?: any) => await fetch(url, options),
token: medplumToken
});boogiecoco.
10/17/2023, 10:08 PMrahul1
10/17/2023, 10:17 PMrahul1
10/17/2023, 10:18 PMMedplumProvider) is on the browser side. Next doesn't clone it to the server for you: https://vercel.com/guides/react-context-state-management-nextjsboogiecoco.
10/17/2023, 10:21 PMboogiecoco.
10/17/2023, 10:22 PMrahul1
10/17/2023, 10:23 PMrahul1
10/17/2023, 10:23 PMboogiecoco.
10/17/2023, 10:23 PMrahul1
10/17/2023, 10:24 PMrahul1
10/17/2023, 10:38 PM