Function Signature
Parameters
The unique identifier of the document room to delete.
Return Value
This function does not return a value. On success, it redirects to the home page (
/).Usage Example
Error Handling
The function enforces strict permission requirements before allowing deletion:Behavior
After successful deletion, the function:
- Revalidates the root path (
/) to update the documents list - Automatically redirects the user to the home page
Implementation Details
- Permission Verification: Checks for write access before allowing deletion
- Permanent Deletion: Removes the room and all associated data from Liveblocks
- Automatic Redirect: Uses Next.js
redirect()to navigate to/after deletion - Cache Revalidation: Calls
revalidatePath('/')to update the documents list
Side Effects
- Deletes the room from Liveblocks
- Revalidates the cache for the home page
- Redirects the user to the home page
Permission Requirements
Only users with
room:write permissions can delete documents. This typically includes:- Document creator (owner)
- Collaborators with editor access
room:read access cannot delete documents.Related Functions
createDocument- Create a new documentgetDocument- Retrieve a documentupdateDocument- Update document metadataremoveCollaborator- Remove a collaborator
Related Types
Source
Defined inlib/actions/room.actions.ts:201