> ## Documentation Index
> Fetch the complete documentation index at: https://docs.divvi.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Extend Divvi apps using Hooks

export const EditPage = ({editUrl, lastModified}) => {
  const formatDate = isoString => {
    if (!isoString) return null;
    try {
      const date = new Date(isoString);
      return date.toLocaleString("en-US", {
        dateStyle: "medium",
        timeStyle: "short"
      });
    } catch {
      return null;
    }
  };
  const formattedDate = formatDate(lastModified);
  return <div className="pt-6 mt-6 mb-6">
      <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
        <a href={editUrl} target="_blank" rel="noopener noreferrer" className="inline-flex items-center gap-1.5 text-sm font-medium text-primary no-underline not-prose">
          <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
            <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path>
            <path d="m18.5 2.5 3 3L12 15l-4 1 1-4 9.5-9.5z"></path>
          </svg>
          Suggest changes to this page
        </a>
        {formattedDate && <span className="text-sm text-gray-500 not-prose">
            Last updated: {formattedDate}
          </span>}
      </div>
    </div>;
};

> If you want to start coding, check out the [Live
> Preview](./live-preview) and the [example application](https://github.com/divvi-xyz/hooks/blob/master/src/apps/example)
> with hook implementations.

Divvi Hooks is a system that allows developers to extend apps (*e.g.*, the Valora wallet and other Divvi apps) by
writing short programs called "hooks". Divvi apps will call hooks in
response to certain in-app or blockchain events and use the results
from hooks to extend the apps' functionality.

Divvi Hooks is currently an experimental feature. We are
developing the Divvi Hooks system incrementally based on feedback
from developers. Eventually we hope developers will be able to publish
hooks that users can enable or disable at will.

## Example: position pricing

Users often hold asset-like positions with dapps that are specific to
the dapp implementation. For example, DeFi dapps
implement yield farms with smart contracts specific to the dapp and
these contracts track each users' state in the yield farm, like
liquidity and unclaimed rewards. A developer can implement a Divvi
hook to detect these types of positions and price them. If a user is
yield farming they will see their yield farm positions directly in
the app.

## Developing a hook

A developer can write a short TypeScript program that handles a
specific hook type. A user's Divvi wallet passes information to the
hook, the hook executes in an isolated environment and returns a
result, and the app uses the results to extend its default behavior.

Currently all hooks need to be approved by a Valora engineer before
being available to users in the app. Please contact us if
you're interested in developing a hook and haven't chatted with us
yet.

## Hook types

Divvi supports or is working on support for the types of hooks we
list below:

* Position pricing: show a custom contract position in a Divvi app
* Name resolution: map an arbitrary identifier or name to a wallet address
* Shortcut (coming soon): complete simple dapp (or inter-dapp) actions
  within a Divvi app

We plan on adding support for more hook types. If you have a request
please reach out on Discord.

## Contact

`#hooks-dev` on Divvi's discord.

## Related work

* [https://docs.metamask.io/snaps/](https://docs.metamask.io/snaps/)
* [https://zapper.xyz/](https://zapper.xyz/)

<EditPage editUrl="https://github.com/divvi-xyz/hooks/edit/main/docs/index.md" lastModified="2025-02-19T14:27:25.000Z" />
