> ## 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.

# Divvi Hooks Platform

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>;
};

## Developing a hook

Developers must implement hooks in TypeScript and integrate them with
one of the existing per-hook type GitHub repositories.

We hope to make hooks easy to develop but also want to easily iterate
on the Divvi Hooks Platform for developing and deploying hooks. For
now we require all deployed hook code to be located in Divvi GitHub
repositories so we can help improve and maintain them (e.g., when
we implement breaking changes to the platform), but in the future we
expect to impose fewer requirements on how hooks are developed.

## Execution environment

Each hook executes in a Node.js 20 environment. Currently we
implement this as a [Google Cloud
Function](https://cloud.google.com/functions/docs/concepts/execution-environment), which has several important implications:

* statelessness: your hook cannot store data locally (*e.g.*, in memory)
* timeout: the app will timeout waiting for a hook to execute
* background: the app destroys the hook environment after it returns so
  it's not possible to continue computation in the hook after
  returning a result

Eventually every hook will execute in a sandboxed JavaScript
environment (like [Secure ECMAScript
(SES)](https://github.com/endojs/endo/tree/master/packages/ses), which
MetaMask Snaps use) and we encourage hook developers to have that
high-level model in mind when developing their hooks and avoid
depending on Google Cloud Function specific attributes (*e.g.*, reading
the reserved environment variable `K_SERVICE`)

## Deploying a hook to a Divvi app

To deploy your hook you must:

1. submit a PR to the appropriate GitHub repository and work with a
   Valora engineer to merge your PR; and
2. confirm with a Valora engineer that they added your hook to the
   list of enabled hooks.

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