Docs/Quick Start

Quick Start

Import the component and its stylesheet, then control visibility with a state variable.

App.tsx
import { useState } from 'react'
import { Popout } from 'react-marketing-popups'
import 'react-marketing-popups/Popout/style.css'

export default function App() {
  const [open, setOpen] = useState(false)

  return (
    <>
      <button onClick={() => setOpen(true)}>Open Popup</button>

      <Popout
        id="my-popup"
        open={open}
        onOpenChange={setOpen}
        animation="zoom"
        lockScroll
      >
        <div style={{ padding: 32 }}>
          <h2>Hello World!</h2>
          <button onClick={() => setOpen(false)}>Close</button>
        </div>
      </Popout>
    </>
  )
}

Persistence

The id prop is required. The library uses it as a localStorage key to record when a popup was last shown. By default, each popup shows once per session. Use the showCount and cooldownMs props to tune this behaviour — see usePersistence for the hook-based version of the same idea.

Next steps

Browse the live, working demos under Components, or read Concepts for how Popout, SlideIn, and Banner relate to each other and to the trigger hooks.