Anything integration rules

This page is the detailed rule set referenced by the Anything starter prompt. It exists so the prompt you paste into the builder can stay short; the agent fetches this page and follows the rules below. It is intentionally kept out of the sidebar.

Anything builds React apps, so use the @addresszen/react component. It renders its own <input>, attaches the widget and hands the selected address back through onAddressRetrieved, with no <script> tags, useEffect loaders, CSS selectors or controlled/uncontrolled juggling. The one thing left to get right is delivering the API key from a Saved Secret to the browser. The rules below cover both.

Install the package​

  • Install @addresszen/react and import the component: import { AddressLookup } from "@addresszen/react";. It pulls in @addresszen/address-lookup automatically. Do not inject a <script> tag in JSX; React does not execute script tags rendered that way, and you don't need one: import the component from npm.

Wiring the widget​

  • Render the component and read the resolved address from onAddressRetrieved:

    import { AddressLookup } from "@addresszen/react";
    
    <AddressLookup
      apiKey={apiKey}
      onAddressRetrieved={(address) => {
        setForm({
          line_1: address.line_1,
          line_2: address.line_2,
          city: address.city,
          state: address.state,
          zip_plus_4_code: address.zip_plus_4_code,
          country: address.country,
        });
      }}
    />
  • The component defaults to US addresses. It draws its own search <input>. To reuse a styled input, pass it as a single child instead (wrap mode): <AddressLookup apiKey={apiKey} ...><input className="..." /></AddressLookup>.

  • Populate every other field from the onAddressRetrieved callback into React state. Those fields are controlled (value + onChange) as normal; the component never writes to them directly.

  • The stylesheet is auto-injected by default (injectStyle defaults to true), so the dropdown is styled out of the box. No separate CSS import is required.

API key​

  • Add a backend function at web/api/azen-config/route.ts that reads the ADDRESSZEN_API_KEY Saved Secret and returns it to the frontend. Fetch it on mount into state and pass it as the apiKey prop. Render <AddressLookup> only once the key has arrived. Do not hardcode the key.

Errors​

  • Pass onSearchError and onSuggestionError props. If the AddressZen API returns a 4xx error, surface the error's message to the user. Do not swallow it.

Reference docs​