Détail du package

sonner-native

gunnartorfis168.2kMIT0.21.1

An opinionated toast component for React Native. A port of @emilkowalski's sonner.

react-native, ios, android, toast

readme

React Native Toasts

An opinionated toast component for React Native. A port of @emilkowalski's sonner.

sonner-native

Features

  • API fully matches Sonner's
  • Multiple variants, including success, error, warning, custom, promise
  • Promise variant with built-in loading state
  • Custom JSX with the custom variant
  • Top or bottom positions
  • Title and description
  • Action button with a callback
  • Custom icons
  • Optionally dismissable with swipe, configurable left or up
  • Dismissable with toast.dismiss(), one or all toasts
  • Highly performant using Reanimated 3, 60 FPS
  • Dark mode built-in
  • Works with Expo
  • NativeWind supported
  • Customizable via styles props
  • Works outside of React components

Showcase

Screenshot 2024-09-06 at 16 33 10 Screenshot 2024-09-06 at 16 32 27 Screenshot 2024-09-06 at 16 32 33 Screenshot 2024-09-06 at 16 32 39 Screenshot 2024-09-06 at 16 33 04

Expo Snack

https://snack.expo.dev/@gunnartorfis/sonner-native

Installation

npx expo install sonner-native

Requirements

To use this package, you also need to install its peer dependencies. Check out their documentation for more information:

Usage

In your App.tsx/entry point

import { Toaster } from 'sonner-native';

function App() {
  return (
    <View>
      <NavigationContainer>...</NavigationContainer>
      <Toaster />
    </View>
  );
}

Show a toast

import { toast } from 'sonner-native';

function SomeComponent() {
  return (
    <Button
      title="Show Toast"
      onPress={() => toast('Hello, World!')}
    />
  );
}

Web support

Even though Sonner Native works on the web, it is not recommended to use it there. Instead, use the original Sonner.

The following setup is recommended. Add a sonner.ts and sonner.web.ts file to your project and import from there instead of from this library directly. That way, sonner will be used on the web and sonner-native on native.

// sonner.ts
export * from 'sonner-native';
// sonner.web.ts
export * from 'sonner';

Documentation

For more advanced usage, check out the documentation

Recording

https://github.com/user-attachments/assets/ccc428ca-37c3-4589-9e8c-f414c40d764c

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

changelog

0.21.0 (2025-06-10)

Features

  • add elastic resistance for toast wrong-direction gestures (bb345b4)

0.20.0 (2025-05-14)

0.20.0-beta.0 (2025-05-14)

Bug Fixes

  • attempt to fix android crash (4c9f042)

0.19.1 (2025-05-10)

Bug Fixes

  • temporarily disable opacity gesture animation on Android (350ac2f)
  • the missed style props for the toaster props (27200a1)

0.19.0 (2025-04-01)

Features

0.18.1 (2025-04-01)

Bug Fixes

0.18.0 (2025-03-31)

0.18.0-beta.0 (2025-03-29)

Bug Fixes

  • bottom positioned toast animation fix (8196552)
  • set full width to ToastWrapper by default (5b196ca)
  • updating toasts race condition (393f6bb)

Features

  • add a ToastWrapper to wrap the toast with a custom component (0040467)

0.17.0 (2025-02-04)

0.16.2 (2024-12-10)

Bug Fixes

  • let animation finish before hiding toasts (cf4ed8e)

0.16.1 (2024-11-19)

Bug Fixes

  • custom jsx component breaks animation (fab7d6f)
  • render custom jsx in if block and use ToastSwipeHandler with memoized props (61e5ead)

0.16.0 (2024-11-05)

0.16.0-beta.0 (2024-10-27)

Bug Fixes

  • conditional full window overlay (d6f8990)

0.15.0 (2024-10-04)

Bug Fixes

Features

  • added customizeable close button (98855df)

0.14.2 (2024-09-22)

Bug Fixes

  • add missing worklet directive (b5796de)

0.14.1 (2024-09-20)

Bug Fixes

  • close button press didn't trigger dismiss (d83a529)

0.14.0 (2024-09-19)

Bug Fixes

  • android action onclick (5e8a4b0)
  • handle dismissible false with onPress (c10b936)
  • toastOption.style wasn't applied (b13ea69)

Features

  • add onPress (102e092)
  • toast.promise error option can be a callback fn or a string (89d0872)

0.13.0 (2024-09-14)

Bug Fixes

  • await the promise to be able to catch its error and render an error toast (671fb5d)
  • bottom positioned toast should swipe down (6051c62)
  • corrected typo in "swipeToDismissDirection" prop (f2c9788)
  • renamed "ivertProps" to "invertProps" in "use-colors.ts" (411ecf2)

Features

0.12.1 (2024-09-11)

Bug Fixes

  • crash when trying to wiggle duration Infinity (3e81b34)

0.12.0 (2024-09-11)

Bug Fixes

  • reset duration on wiggle (e927659)

0.12.0-alpha.0 (2024-09-11)

Features

  • wiggle toasts on update + toast.wiggle() (de60ddc)

0.11.0 (2024-09-11)

Features

  • more accurately represent Sonner's way of styling via the Toaster (aefd6c4)

0.10.1 (2024-09-10)

0.10.0 (2024-09-10)

Features

  • wrap Toaster with the ToasterOverlayWrapper prop (e1dee05)

0.9.2 (2024-09-10)

Bug Fixes

  • custom icons not rendering with <CssInterop.xx /> (c7f281d)
  • theme was not used when passed to Toaster (34904f5)

0.9.1 (2024-09-09)

Bug Fixes

  • updating toasts is now more stable (2260ed7)

0.9.0 (2024-09-09)

Bug Fixes

  • custom id was trying to update an existing toast (83f2f49)
  • passing invert to toast() now works (4de18df)
  • pull request template directory (0dab465)
  • remove hard code (8eed260)

Features

  • add pull request template (afb4daa)

0.8.3 (2024-09-09)

Bug Fixes

  • respect the gap value passed via <Toaster /> (2cb5f02)

0.8.2 (2024-09-09)

0.8.1 (2024-09-09)

Bug Fixes

  • warning by y gesture handler (3e11b91)

0.8.0 (2024-09-08)

Features

  • dynamic positioning (676cbc7)
  • important accessibility settings for Androi (a663f65)

0.7.0 (2024-09-08)

Bug Fixes

  • bottom bars weren't tappable with custom offset (cc664a5)

Features

  • custom loading icon (881ab67)
  • pause timer when app enters background (2a1a2c5)
  • pause timer when app enters background (d6e04e7)
  • remove cn as dependency and add is as a prop (464d800)
  • warning variant (4cc58e8)

0.6.0 (2024-09-08)

Features

0.5.0 (2024-09-07)

Bug Fixes

Features

0.4.1 (2024-09-07)

Bug Fixes

0.4.0 (2024-09-06)

Bug Fixes

  • matching sonner's api more, refactor types (eba154a)
  • reset duration on toast update (aabb673)
  • separate onDismiss & onAutoClose callbacks (9122f22)

Features

  • closeButton prop to show X or not (22b64a6)
  • custom icons (481903b)
  • custom icons (d7c4829)
  • customize toasts with styles (876eaaa)
  • dismissible prop to make a toast non-swipable nor X to close (130a1ef)
  • fully customizable, every view with style (9e53391)
  • invert prop (8887cd3)
  • new onAutoClose callback (dc28ea9)
  • support Infinity duration (47ac273)
  • toast.dismiss() (5b996ec)
  • unstyled prop to Toaster (ff56e30)

0.3.9 (2024-09-05)

0.3.8 (2024-09-05)

0.3.7 (2024-09-05)

Bug Fixes

0.3.6 (2024-09-05)

Bug Fixes

0.3.5 (2024-09-05)

0.3.4 (2024-09-05)

0.3.3 (2024-09-05)

0.3.2 (2024-09-05)

0.3.1 (2024-09-05)