https://github.com/tonysantana1492/sonner-ssr
An opinionated toast component for Next based on sonner
https://github.com/tonysantana1492/sonner-ssr
message next notifications react server-components snackbar ssr toast
Last synced: 6 months ago
JSON representation
An opinionated toast component for Next based on sonner
- Host: GitHub
- URL: https://github.com/tonysantana1492/sonner-ssr
- Owner: tonysantana1492
- License: mit
- Created: 2025-02-03T02:56:27.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-10T03:21:08.000Z (8 months ago)
- Last Synced: 2025-03-29T22:16:17.438Z (6 months ago)
- Topics: message, next, notifications, react, server-components, snackbar, ssr, toast
- Language: TypeScript
- Homepage:
- Size: 2.59 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Sonner-SSR is a specialized toast component designed for Next.js applications, inspired by the [Sonner](https://sonner.emilkowal.ski/) library. It offers a streamlined and opinionated approach to displaying toast notifications within the Next.js framework.
## Features
- Seamless integration with Next.js
- Customizable themes
- Easy-to-use API
- Lightweight and performant## Installation
To start using the library, install it in your project:
```bash
npm install sonner-ssr
```## Usage
Create a `` component.
```jsx
"use client";import { useTheme } from "next-themes";
import { Toaster } from "sonner-ssr";type ToasterProps = React.ComponentProps;
const ToasterProvider = ({ ...props }: ToasterProps) => {
const { theme = "system" } = useTheme();return (
);
};export { ToasterProvider };
```Add `` to your app. It will be the place where all your toasts will be rendered. After that, you can use `toast()` from anywhere in your app.
```jsx
'use server';import type { PropsWithChildren } from 'react';
import { ToasterProvider } from 'sonner-ssr';export default function RootLayout({ children }: PropsWithChildren) {
return (
{children}
);
}
```## Example
Here's an example of how to trigger a toast notification:
```jsx
import { toast } from 'sonner-ssr';function notify() {
toast('This is a toast notification!');
}
```## Documentation
Find the full API reference in the [documentation](https://sonner.emilkowal.ski/getting-started).