# Sign-in & sign-out with NearFi

## Signing in

Once NearFi wallet object is available (see [here](/developer-guide/integrate-nearfi-dapp-browser-into-your-app/detecting-nearfi-wallet-provider-ready.md)), it is recommended for applications to request approval from users to sign-in the applications.\
\
Example code to request sign-in:<br>

```javascript
//request permission to call any function of your contract application 
const signInResponse = await window.nearFiWallet.requestSignIn({
  contractId: "your-contract-id", // the contract Id of your application
});
if (signInResponse.error) {
  console.log("failed to sign-in")
} else {
  console.log("sign-in success")
}

//you can also use promise to request
window.nearFiWallet.requestSignin({
  contractId: "your-contract-id", // the contract Id of your application
}).then(signInResponse => {})

// Or add `methodNames` if your contract application only needs permission for some of the methods
await window.nearFiWallet.requestSignIn({
  contractId: "your-contract-id", // the contract Id of your application
  methodNames: ["method1", "method2"]       // (optional) changed methods the app allowed to use
});
```

The response of `requestSignIn` function also has an access key information. More details on the response can be found [here](https://github.com/DegaLabs/wallet-selector/blob/37ca783acc64c141b521d264f1b8fca2e8945c21/packages/nearfi/src/lib/injected-nearfi.ts#L14).\
\
Once successfully signed in, function `window.nearFiWallet.isSignedIn()` will return `true`.

![](/files/2FUe5V7BxoALmywJgLbw)

## Signing out

API `signOut` serve the function of singing out when a user wants to disconnect the wallet from the applications.

```javascript
await window.nearFiWallet.signOut();
```

![](/files/qhCCkqzk6MZYBTy5J6kQ)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nearfi.finance/developer-guide/integrate-nearfi-dapp-browser-into-your-app/sign-in-and-sign-out-with-nearfi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
