This guide assumes that you have completed the Quickstart.
C1ShareThread component. You provide a generateShareLink(messages) function; the SDK gathers messages, opens a modal, and handles copying/confirmation.
1
Frontend: Add a Thread Share trigger
First, destructure the
C1Chat component as explained the Integrating Custom Components guide, so that you can integrate a custom header. Next,
use the C1ShareThread component to display a share button in your chat header, which automatically opens a modal to generate a share link using the generateShareLink function you defined.The updated code for the chat page will look something like this:page.tsx
2
Frontend: Add a component to render the shared thread
Create a route and component on the frontend to render the shared thread:
/app/shared/[threadId]/page.tsx
3
Backend: Implement the thread share endpoint
Implement an endpoint that returns the thread for a given
threadId.Implement a message store to store the message history. If you’ve followed the Quickstart, you’ll have a message store already, which you can move
to a common location (such as
/lib/messageStore.ts) and modify it to persist message history across API routes and requests as follows:/lib/messageStore.ts
/app/api/share/[threadId]/route.ts
4
Test
- Open a conversation with multiple messages.
- Click the thread share button.
- Generate and copy the link from the modal.
