Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sonner-native

Package Overview
Dependencies
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sonner-native

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

  • 0.15.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2K
increased by11.17%
Maintainers
0
Weekly downloads
 
Created
Source

Sonner Native

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, styles & className 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

Keywords

FAQs

Package last updated on 04 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc