Native Toast
API Reference

Types

TypeScript types exported by @ncrft/native-toast.

Toast

The core toast object managed by the store.

type Toast = {
  id: string;
  type: ToastType;
  message: ToastMessage;
  visible: boolean;
  duration: number;
  icon?: string | React.ReactNode;
  style?: ViewStyle;
  textStyle?: TextStyle;
  createdAt: number;
  iconShown?: boolean;
};
FieldTypeDescription
idstringUnique identifier (auto-generated t_N or custom)
typeToastTypeToast variant (blank, success, error, loading, custom)
messageToastMessageThe content to display
visiblebooleanWhether the toast is in its visible/animated state
durationnumberAuto-dismiss duration in ms (Infinity for loading)
iconstring | React.ReactNodeOptional custom icon override
styleViewStyleOptional style override for the toast container
textStyleTextStyleOptional style override for the toast text
createdAtnumberCreation timestamp (ms since epoch)
iconShownbooleanWhether the icon is currently displayed

ToastOptions

Options accepted by all toast.* methods.

type ToastOptions = {
  duration?: number;
  id?: string;
  icon?: string | React.ReactNode;
  style?: ViewStyle;
  textStyle?: TextStyle;
};
FieldTypeDefaultDescription
durationnumberVaries by typeAuto-dismiss time in ms. Use Infinity to prevent auto-dismiss.
idstringAuto-generatedCustom ID. Same ID updates existing toast (upsert).
iconstring | React.ReactNodeBuilt-in per typeIcon override. String = emoji/text, element = any React node.
styleViewStyleStyle override for the toast container
textStyleTextStyleStyle override for the toast text

ToastType

type ToastType = 'blank' | 'success' | 'error' | 'loading' | 'custom';

ToastTheme

type ToastTheme = 'dark' | 'light';

ToastMessage

The message parameter accepts three forms:

type ToastMessage =
  | string
  | React.ReactNode
  | ((toast: Toast) => React.ReactNode);
FormDescription
stringPlain text message
React.ReactNodeAny renderable React content (views, images, text, etc.)
(toast) => React.ReactNodeRender function that receives the toast object for conditional rendering
// string
toast.success('Saved!');

// ReactNode
toast.custom(<View><Text>Custom</Text></View>);

// Render function
toast.custom((t) => (
  <Text>{t.visible ? 'Visible' : 'Hidden'}</Text>
));

Full Export List

import {
  toast,           // Imperative API object
  useToaster,      // Timer management hook
  useToasterStore, // State subscription hook
  ToastContainer,  // Root overlay component
  useTheme,        // Theme reader hook
  setTheme,        // Theme setter function
  type Toast,
  type ToastOptions,
  type ToastType,
  type ToastTheme,
  type ToastMessage,
} from '@ncrft/native-toast';

On this page