NhostReactClientConstructorParams

Parameters


adminSecret optional string

When set, the admin secret is sent as a header, x-hasura-admin-secret, for all requests to GraphQL, Storage, and Serverless Functions.


functionsUrl optional string


storageUrl optional string


graphqlUrl optional string


authUrl optional string


region optional string

Project region (e.g. eu-central-1) Project region is not required during local development (when subdomain is localhost)


subdomain optional string

Project subdomain (e.g. ieingiwnginwnfnegqwvdqwdwq) Use localhost during local development


devTools optional boolean

Activate devTools e.g. the ability to connect to the xstate inspector


autoSignIn optional boolean

When set to true, will parse the url on startup to check if it contains a refresh token to start the session with


autoRefreshToken optional boolean

When set to true, will automatically refresh token before it expires


clientStorage optional ClientStorage

Object where the refresh token will be persisted and read locally.

Recommended values:

  • 'web' and 'cookies': no value is required

  • 'react-native': use @react-native-async-storage/async-storage

    import { NhostClient } from '@nhost/nhost-js'
    import AsyncStorage from '@react-native-async-storage/async-storage';
    const nhost = new NhostClient({
      ...
      clientStorageType: 'react-native',
      clientStorage: AsyncStorage
    })
    
  • 'custom': an object that defines the following methods:

    • setItem or setItemAsync
    • getItem or getItemAsync
    • removeItem
  • 'capacitor':

    import { NhostClient } from '@nhost/nhost-js'
    import { Storage } from '@capacitor/storage'
    const nhost = new NhostClient({
      ...
      clientStorageType: 'capacitor',
      clientStorage: Storage
    })
    
    import { NhostClient  } from '@nhost/nhost-js';
    import { Preferences } from '@capacitor/preferences';
    const nhost = new NhostClient({
      ...
      clientStorageType: 'custom',
      clientStorage: {
        setItemAsync: async (key, value) => Preferences.set({ key, value }),
        getItemAsync: async (key) => {
          const { value } = await Preferences.get({ key });
          return value;
        },
        removeItem(key): (key) => Preferences.remove({ key })
      },
    });
    
  • 'expo-secure-store': use expo-secure-store

      import { NhostClient } from '@nhost/nhost-js'
      import * as SecureStore from 'expo-secure-store';
      const nhost = new NhostClient({
        ...
        clientStorageType: 'expo-secure-store',
        clientStorage: SecureStore
      })
    

clientStorageType optional ClientStorageType

Define a way to get information about the refresh token and its exipration date.

@default

web


refreshIntervalTime optional number

Time interval until token refreshes, in seconds