Installation

You can install Peek using npm or include it directly via CDN.

Using npm:

npm install peek-notify

Using CDN:

<script src="https://unpkg.com/peek-notify/dist/peek.min.js"></script>

Basic Usage

Initialize Peek and show your first notification:

// Initialize Peek
const peek = new Peek();

// Show a simple notification
peek.show({
    title: 'Hello!',
    message: 'Welcome to Peek notifications.'
});

Configuration Options

Customize Peek's behavior with these configuration options:

const peek = new Peek({
    duration: 5000,      // Duration in milliseconds
    maxToasts: 3        // Maximum number of toasts
});
Option Type Default Description
duration number 5000 Duration in milliseconds before toast disappears
maxToasts number 3 Maximum number of toasts to show at once

Notification Types

Peek supports different types of notifications:

// Success notification
peek.success('Operation completed!', 'Success');

// Error notification
peek.error('Something went wrong!', 'Error');

// Warning notification
peek.warning('Please be careful!', 'Warning');

// Info notification
peek.info('Here is some information.', 'Info');

API Reference

Methods

Method Parameters Description
show(options) { title?, message, type?, duration? } Show a notification with custom options
success(message, title?) message: string, title?: string Show a success notification
error(message, title?) message: string, title?: string Show an error notification
warning(message, title?) message: string, title?: string Show a warning notification
info(message, title?) message: string, title?: string Show an info notification
© 2025 Kerem Akman