Skip to content

This document explains the formatting rules for a Google Sheet that manages error content.

Quick Start with Template

Copy the pre-configured template to get a sheet with the correct column structure and sample data.

Copy Google Sheets Template

TIP

After copying, edit the data and run huh pull.


Sheet Column Structure

The first row must be a header row, using the following column names:

Column NameRequiredDescription
trackIdYesUnique ID identifying the error (e.g., ERR_LOGIN_FAILED)
typeYesError display type: TOAST, MODAL, PAGE, or custom type
messageYesError message shown to the user
titleError title (used for modal, page)
imageImage URL (used for page)
severitySeverity level: INFO, WARNING, ERROR, CRITICAL, or custom severity
actionLabelAction button text
actionTypeAction kind: REDIRECT, RETRY, BACK, DISMISS, or custom action
actionTargetAction target URL (required for REDIRECT)

Error Types (type)

Built-in types:

TypeUse CaseRecommended Fields
TOASTSimple notification messageUse message only. Warning if title/image are used
MODALPopup-style error noticemessage + title + action
PAGEFull-screen error pagemessage + title + image + action (warning if no action)

TIP

Custom types (BANNER, SNACKBAR, etc.) can also be used freely. Even if entered in lowercase, they are automatically converted to uppercase.

Action Types (actionType)

Built-in action types:

TypeBehaviorRequires target
REDIRECTNavigate to specified URLYes (actionTarget with URL)
RETRYClose error + execute retry callbackNo
BACKBrowser back (history.back())No
DISMISSClose error UINo

TIP

Custom action types (OPEN_CHAT, SHARE, etc.) can also be used. Handle them via the HuhProvider's onCustomAction callback.

Template Variables

You can use template variables in the format in messages, titles, action labels, and action targets. Variables are passed at runtime when calling huh.

Message example: {{userName}}, your request could not be processed.
Target example: /user/{{userId}}/settings

Examples

trackIdtypemessagetitleimageseverityactionLabelactionTypeactionTarget
ERR_NETWORKTOASTPlease check your network connectionWARNING
ERR_AUTHMODALAuthentication is requiredLogin RequiredERRORLoginREDIRECT/login
ERR_TIMEOUTMODALThe request has timed outTimeoutERRORTry AgainRETRY
ERR_FORBIDDENPAGE does not have access permissionAccess Denied/img/403.pngCRITICALGo BackBACK
ERR_NOT_FOUNDPAGEPage not found404/img/404.pngINFOGo HomeREDIRECT/

Rules Summary

  • Rows with an empty trackId are ignored
  • trackId, type, and message are required
  • type must not be empty (built-in: TOAST, MODAL, PAGE; custom types also allowed)
  • actionTarget is required when actionType is REDIRECT
  • Lowercase input is automatically converted to uppercase by the CLI
  • actionLabel and actionType must be provided together (both present or both absent)

Google Sheet Access Configuration

To access the sheet from the CLI, one of the following authentication methods is required:

Method 1: API Key (for public sheets)

  1. Create a project in the Google Cloud Console
  2. Enable the Google Sheets API
  3. Generate an API Key
  4. Set the sheet to "Anyone with the link can view"
  5. Set the environment variable: GOOGLE_API_KEY=your-api-key

Method 2: Service Account (for private sheets)

  1. Create a service account in the Google Cloud Console
  2. Download the JSON key file
  3. Grant "Viewer" permission to the service account email in the sheet
  4. Specify the credentials path in the config file:
json
{
  "source": {
    "type": "google-sheets",
    "sheetId": "YOUR_SHEET_ID",
    "credentials": "./service-account.json"
  },
  "output": "./src/huh.json"
}

Released under the MIT License.