Quick start with React
Render a week view with a few events, then let people drag them around.
1. Install
Section titled “1. Install”The calendar needs a date adapter. This guide uses date-fns; the others work the same way.
npm install @weekwise/react @weekwise/adapter-date-fns date-fnspnpm add @weekwise/react @weekwise/adapter-date-fns date-fnsyarn add @weekwise/react @weekwise/adapter-date-fns date-fns2. Render the calendar
Section titled “2. Render the calendar”Wrap the calendar in a DateLocalizationProvider with an adapter. Then tell the calendar how to
read your events: a key and a start–end pair. The children render one event card.
import { useState } from "react";import Calendar, { DateLocalizationProvider } from "@weekwise/react";import { DateFnsAdapter } from "@weekwise/adapter-date-fns";import "@weekwise/react/styles.css";
type Event = { id: string; title: string; start: Date; end: Date };
export function Schedule({ initial }: { initial: Event[] }) { const [events, setEvents] = useState(initial);
return ( <DateLocalizationProvider adapter={DateFnsAdapter}> <Calendar style={{ height: 600 }} scrollable items={events} eventKeyResolver={(event) => event.id} eventTimeFrameResolver={(event) => ({ start: event.start, end: event.end })} onEventChange={(event, start, end) => setEvents((prev) => prev.map((e) => (e.id === event.id ? { ...e, start, end } : e))) } onEventCreate={(start, end) => setEvents((prev) => [...prev, { id: crypto.randomUUID(), title: "New event", start, end }]) } > {(event) => <div>{event.title}</div>} </Calendar> </DateLocalizationProvider> );}adapter accepts either a class (DateFnsAdapter) or a ready instance
(new DateFnsAdapter({ locale: fr })). Create the instance outside the component, or memoize it,
so the context value stays stable.
Next steps
Section titled “Next steps”- Rendering events: style the cards, flatten the edges of multi-day events.
- Interactions: what each gesture does and how to limit it.
@weekwise/reactreference: every prop, and Next.js notes.