Overview
TheAddDocumentBtn component provides a button that creates a new collaborative document and navigates the user to it. It’s used on the home page to allow users to start new documents.
Props
The Clerk user ID of the authenticated user creating the document.
The email address of the authenticated user. Used for document ownership and access control.
Features
- One-click creation: Creates a new document and navigates to it automatically
- Responsive text: Shows “Start a blank document” on desktop, icon-only on mobile
- Loading states: Handles async document creation
- Error handling: Logs errors if document creation fails
- Gradient styling: Uses
gradient-blueclass for visual prominence
Usage Example
On Home Page
Fromapp/(root)/page.tsx:
In Empty State
Implementation
The component uses thecreateDocument server action and Next.js router for navigation:
Visual Elements
- Icon: Plus icon from
/assets/icons/add.svg(24x24px) - Text: “Start a blank document” (hidden on mobile via
sm:block) - Styling: Blue gradient background with shadow (
gradient-blue flex gap-1 shadow-md)
Type Definition
Fromtypes/index.d.ts:
Related Components
- DeleteModal - Delete documents
- CollaborativeRoom - Document editing interface
- ShareModal - Share documents with collaborators
Related Functions
- createDocument - Server action called by this component
Source Reference
components/AddDocumentBtn.tsx