A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mongodb.com/docs/atlas/device-sdks/sdk/react-native/api-reference/app-provider/ below:

AppProvider (@realm/react) - Atlas Device SDKs

AppProvider(props, context?): null | ReactElement<any, any>

Components nested within AppProvider can access your App Services App and use the AppProvider hooks.

All properties of AppConfiguration can be passed as props to AppProvider.

To set up your App client, pass the App ID string to the id prop of the AppProvider. Wrap any components that need to access the App with AppProvider.

import React from 'react';import {AppProvider} from '@realm/react';function AppWrapper() {  return (    <View> <AppProvider id={APP_ID}> <MyApp /> </AppProvider> </View>  );}

You can create multiple App client instances to connect to multiple Apps. All App client instances that share the same App ID use the same underlying connection.

Important Changing an App Config After Initializing the App

Changed in version realm@12.6.0: baseUrl is not cached

When you initialize the App client, the configuration is cached internally. Attempting to "close" and then re-open an App with a changed configuration within the same process has no effect. The client continues to use the cached configuration.

Starting with React Native SDK version 12.6.0, the baseUrl in the AppConfiguration is not cached. This means that you can change the baseUrl and the App client will use the updated configuration. In earlier SDK versions, changes to the baseUrl in a cached App configuration have no effect.

useAuth has an authentication method for every App Services authentication provider.

Result of authentication hook operation. For example, result.operation gives you the name of the current operation.

Enum values

logIn(credentials: Realm.Credentials): void

Parameters

Example

Logs in a user with any authentication mechanism supported by Realm. If called when a user is logged in, the current user switches to the new user. Usually, it's better to use the more specific login methods.

const {logIn, result} = useAuth();useEffect(() => logIn(Realm.Credentials.anonymous()), []);if(result.pending) {  return (<LoadingSpinner/>)}if(result.error) {  return (<ErrorComponent/>)}if(result.success) {  return (<SuccessComponent/>)}
logInWithAnonymous(): void

Example

Log in with the anonymous authentication provider.

const {logInWithAnonymous, result} = useAuth();const performLogin = () => {   logInWithAnonymous();};
logInWithApiKey(key: string): void

Parameters

Example

Log in with an API key.

const {logInWithApiKey, result} = useAuth();const performLogin = () => {const key = getApiKey();    logInWithApiKey(key);};
logInWithEmailPassword(credentials: {  email: string;  password: string;}): void

Parameters

Example

Log in with Email/Password.

const {logInWithEmailPassword, result} = useAuth();const [email, setEmail] = useState('');const [password, setPassword] = useState('');const performLogin = () => {   logInWithEmailPassword({email, password});};
logInWithJWT(token: string): void

Parameters

Example

Log in with a JSON Web Token (JWT).

const {logInWithJWT, result} = useAuth();const performLogin = () => {const token = authorizeWithCustomerProvider();    logInWithJWT(token);};
logInWithGoogle(credentials: {     idToken: string; } | {     authCode: string; }): void;

Parameters

Example

Log in with Google.

const {logInWithGoogle, result} = useAuth();const performLogin = () => {const token = getGoogleToken();    logInWithGoogle({idToken: token});};
logInWithApple(idToken: string): void;

Parameters

Example

Log in with Apple.

const {logInWithApple, result} = useAuth();const performLogin = () => {const token = getAppleToken();    logInWithApple(token);};
logInWithFacebook(accessToken: string): void;

Parameters

Example

Log in with Facebook.

const {logInWithFacebook, result} = useAuth();const performLogin = () => {const token = getFacebookToken();    logInWithFacebook(token);};
logInWithFunction<PayloadType extends Record<string, unknown>>(payload: PayloadType): void;

Parameters

Example

Log in with a custom function.

const {logInWithFunction, result} = useAuth();const performLogin = () => {const customPayload = getAuthParams();    logInWithFunction(customPayload);};

Example

Logs out the current user.

const {logOut, result} = useEmailPasswordAuth();const performLogout = () => {   logOut();}

Result of authentication hook operation. For example, result.operation gives you the name of the current operation.

Enum values

logIn(credentials: { email: string; password: string }): void;

Parameters

Example

Logs a user in using an email and password. You could also call logIn(Realm.Credentials.emailPassword(email, password)). Returns a Realm.User instance of the logged-in user.

const {logIn, result} = useEmailPasswordAuth();const [email, setEmail] = useState('');const [password, setPassword] = useState('');const performLogin = () => {   logIn({email, password});};if(result.pending) {   return (<LoadingSpinner/>)}if(result.error) {   return (<ErrorComponent/>)}if(result.success) {   return (<SuccessComponent/>)}

Example

Logs out the current user.

const {logOut, result} = useEmailPasswordAuth();const performLogout = () => {   logOut();}
register(args: { email: string; password: string }): void;

Parameters

Example

Registers a new user. Requires a user email and password.

const {register, result} = useEmailPasswordAuth();const [email, setEmail] = useState('');const [password, setPassword] = useState('');const performRegister = () => {   register({email, password});};
confirm(args: { token: string; tokenId: string }): void;

Parameters

Example

Confirms a user account. Requires a token and tokenId.

const {confirm, result} = useEmailPasswordAuth();const performConfirmation = () => {   confirm({token, tokenId});};
resendConfirmationEmail(args: { email: string }): void;

Parameters

Example

Resends a confirmation email.

const {resendConfirmationEmail, result} = useEmailPasswordAuth();const [email, setEmail] = useState('');const performResendConfirmationEmail = () => {   resendConfirmationEmail({email});};
retryCustomConfirmation(args: { email: string }): void;

Parameters

Example

Retries confirmation with a custom function.

const {retryCustomConfirmation, result} = useEmailPasswordAuth();const [email, setEmail] = useState('');const performRetryCustomConfirmation = () => {   retryCustomConfirmation({email});};
sendResetPasswordEmail(args: { email: string }): void;

Parameters

Example

Sends a password reset email.

const {sendResetPasswordEmail, result} = useEmailPasswordAuth();const [email, setEmail] = useState('');const performSendResetPasswordEmail = () => {   sendResetPasswordEmail({email});};
resetPassword(args: { token: string; tokenId: string; password: string }): void;

Parameters

Example

Resets a user's password.

const {resetPassword, result} = useEmailPasswordAuth();const [password, setPassword] = useState('');const performResetPassword = () => {   resetPassword({token, tokenId, password});};
callResetPasswordFunction<Args extends unknown[] = []>( args: {   email: string;   password: string; }, ...restArgs: Args): void;

Parameters

Example

Calls your App Services backend password reset function. Can pass arguments to the function as needed.

const {callResetPasswordFunction, result} = useEmailPasswordAuth();const [email, setEmail] = useState('');const [password, setPassword] = useState('');const performResetPassword = () => {   callResetPasswordFunction({email, password}, "extraArg1", "extraArg2");};
useApp<FunctionsFactoryType, CustomDataType>(): Realm.App<FunctionsFactoryType, CustomDataType>

Example

The useApp() hook provides access to a Realm.App instance.

import React from 'react';import {useApp} from '@realm/react';
function MyApp() {  const app = useApp();  }

Returns


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4