Skip to main content
Sublay stores notifications as structured records with typed metadata — not pre-rendered strings. Your app controls how each notification type is displayed using notification templates. Templates are passed to useAppNotifications via the notificationTemplates prop. Each template can define a title and/or content. Each field accepts either:
  • A string with $variable placeholders that are filled from the notification’s metadata, or
  • A function that receives a typed variables object and returns a string — useful when you need full control, such as translating specific values or applying conditional logic.

String template example

Function template example

Function templates are useful when string interpolation isn’t enough — for example, when you need to translate a reaction type value into another language, or apply conditional phrasing.
TypeScript will infer the exact variables available for each notification type, so you get autocompletion and type safety when destructuring the parameter.

Template keys and available variables

Each key in notificationTemplates corresponds to one notification type. The variables available to both string placeholders and function templates are listed below.
All template keys are optional. If a template is not provided for a given notification type, Sublay uses a built-in default string template for that type. You only need to supply the keys you want to customize.

Accessing raw metadata

For building fully custom UIs, access the raw metadata directly on each notification. Every notification includes:
  • id — the notification’s unique ID
  • type — the notification type string
  • isRead — whether the user has read it
  • action — a hint string for the action to take on tap (e.g., "open-entity", "open-comment", "open-profile")
  • metadata — type-specific fields (entity IDs, initiator info, etc.)
  • createdAt — ISO timestamp