Dynamically setting baseURL

Hello, I'm currently building an expo application where the user can set the location of their local server. The issue I'm running into is trying to dynamically set the baseUrl based on what the user enters. I was trying the create a function to initialize the client route, but I've been struggling to get the typings correct with my plugins (expoClient and usernameClient).

let client: ReturnType<typeof createAuthClient> | undefined

export function getAuth() {
  if (!client) {
    const baseURL = storage.getString(STORAGE_KEYS.SERVER_URL)
    client = createAuthClient({
      baseURL,
      plugins: [
        expoClient({
          scheme: 'dev.entro.kaisho',
          storagePrefix: 'dev.entro.kaisho',
          storage: SecureStore
        }),
        usernameClient()
      ]
    })
  }
  return client
}
Was this page helpful?