Skip to main content

Overview

useCreateEvent returns a callable that creates an event. The logged-in user becomes the creator and is auto-added to hostIds. Pass cover and/or gallery to upload images inline — the hook sends multipart/form-data automatically (requires the files-images bundle).

Usage Example

import { useCreateEvent } from "@sublay/react-js";

function CreateEvent() {
  const createEvent = useCreateEvent();

  const handleCreate = async () => {
    const event = await createEvent({
      title: "Launch Party",
      type: "physical",
      startTime: "2026-09-01T18:00:00.000Z",
      endTime: "2026-09-01T22:00:00.000Z",
      venueName: "The Loft",
      address: "123 Main St, New York, NY",
      capacity: 100,
      visibility: "public",
    });
    console.log("Created:", event.id);
  };
}

Parameters

title
string
required
Event title. 1–300 characters.
startTime
string
required
ISO datetime when the event starts.
type
"online" | "physical" | "hybrid"
required
online requires url; physical requires address or location; hybrid requires both.
description
string
Optional description.
endTime
string
Optional ISO end datetime.
timezone
string
Optional IANA timezone.
url
string
Join/stream URL.
venueName
string
Venue name.
address
string
Street address.
location
{ latitude: number; longitude: number }
Coordinates for proximity search.
spaceId
string
Scope to a space. Required when visibility is "members".
visibility
"public" | "members" | "invite"
Defaults to "public".
capacity
number
Max going RSVPs. Omit for unlimited.
allowMaybe
boolean
Allow "maybe" RSVPs. Defaults to true.
guestListVisible
boolean
Expose the named guest list. Defaults to true.
hostIds
string[]
Additional host user IDs (the logged-in user is auto-added).
metadata
Record<string, any>
Arbitrary key-value data. Up to 1 MB.
cover
{ file: File | RNFile; options?: UploadImageOptions }
Single cover image to upload. Sends multipart. Requires the files-images bundle.
Gallery images to upload (up to 10). Sends multipart. Requires the files-images bundle.

Returns

Returns a Promise<Event> — the created Event with inline rsvpCounts.

See Also