> For the complete documentation index, see [llms.txt](https://gitbook.keytrust.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.keytrust.one/passes/sdk/hooks/usepolicies.md).

# usePolicies

The `usePolicies` hook is designed to validate policies against a given wallet address. It acts as a standalone tool for policy validation, similar to how the `<GatedComponent/>` gates content but is used directly within your React components to conditionally render or execute logic based on policy validation results.

To use the `usePolicies` hook, you must have a `walletAddress` and one or more `policyIds`. The hook will return the validation result, along with other useful status flags and data.

```
import React from 'react';
import { usePolicies } from '@ethpass/sdk';

const MyComponent = ({ walletAddress }) => {
  const { valid, data, isLoading, isError, error } = usePolicies(['policy1', 'policy2'], walletAddress);

  if (isLoading) return <div>Loading...</div>;
  if (isError) return <div>Error: {error.toString()}</div>;

  return (
    <div>
      {valid ? (
        <div>Access granted</div>
      ) : (
        <div>Access denied</div>
      )}
      {/* Optionally use data for more detailed rendering */}
    </div>
  );
};

 
```

`usePolicies` accepts the following parameters:

* **`policyIds`** (`string[]`): An array of policy identifiers. These are the policies that will be validated against the provided wallet address.
* **`walletAddress`** (`string`): The wallet address to be validated against the specified policies. Ensure that this address is correctly formatted and non-empty.

The `usePolicies` hook returns an object containing the following properties:

| Name        | Type      | Description                                                                                                                                   |
| ----------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `valid`     | `any`     | Indicates whether the wallet address satisfies all of the specified policies. The type of this property is based on your validation logic.    |
| `data`      | `any`     | Contains additional information returned from the policy validation process, typically including detailed results of the policy checks.       |
| `isLoading` | `boolean` | A flag indicating if the policy validation request is currently in progress. This can be used to show a loading indicator in your UI.         |
| `isError`   | `boolean` | A boolean flag that indicates if an error occurred during the policy validation process.                                                      |
| `error`     | `unknown` | The error object or message, if an error occurred during validation. The type is `unknown` to accommodate various potential error structures. |

Updated about 1 month ago

***

* [Table of Contents](broken://pages/aJ98knoRoV8u70pBxAxz)
* * * [Usage](broken://pages/aJ98knoRoV8u70pBxAxz)
  * [Parameters](broken://pages/aJ98knoRoV8u70pBxAxz)
  * [Return Value](broken://pages/aJ98knoRoV8u70pBxAxz)
