v1.1.11 — Now with React 19 support

Beautiful Snackbars
for React

A tiny, customizable snackbar library for React 16.8–19. Fully customizable, TypeScript-ready, and weighs under 3 kB.

Everything you need, nothing you don't

Designed to drop in and get out of your way.

⚡
Lightweight

Under 3 kB gzipped. No runtime dependencies — just React and your imagination.

🎨
Customizable

Full control over position, duration, colors, close button, and content. Pass any JSX as the message.

⚛️
React 16 – 19

Tested against every major React version from 16 through the latest React 19 release.

🔷
TypeScript

Ships with first-class TypeScript types. Autocomplete and compile-time safety included.

Live Demo

Tweak position, color, and duration then fire a snackbar right in this page.

Position
Color preset
Duration — 4s
4s
Message

Installation

Add @codejq/react-simple-snackbar to your project in seconds.

npm
npm install @codejq/react-simple-snackbar
yarn
yarn add @codejq/react-simple-snackbar
Provider setup — App.jsx
import SnackbarProvider from '@codejq/react-simple-snackbar'

function App() {
  return (
    <SnackbarProvider>
      <YourApp />
    </SnackbarProvider>
  )
}
Hook usage — Component.jsx
import { useSnackbar } from '@codejq/react-simple-snackbar'

function MyComponent() {
  const [openSnackbar, closeSnackbar] = useSnackbar()

  return (
    <button onClick={() => openSnackbar('Hello world!')}>
      Show snackbar
    </button>
  )
}

API

Everything you can pass to useSnackbar(options).

Prop Type Default Description
position string 'center' Where the snackbar appears. One of 7 positions.
style CSSProperties {} Inline styles applied to the snackbar box.
closeStyle CSSProperties {} Inline styles applied to the close button.
openSnackbar(node, duration?) function — Opens the snackbar with the given ReactNode and optional duration in ms.
closeSnackbar() function — Programmatically dismisses the current snackbar.
duration number 6000 Auto-close delay in milliseconds.