Skip to content
Back

Document ID already exists error with ID.unique() in React Native/Expo

  • 0
  • Databases
agerdov422
9 Sep, 2025, 18:23

Problem Summary I'm building a React Native app with Expo and trying to create profile documents in Appwrite when users sign up. I keep getting this error: Error: [AppwriteException: Document with the requested ID already exists. Try again with a different ID or use ID.unique() to generate a unique ID.] What I'm doing: Using ID.unique() to generate document IDs for profiles Creating accounts successfully (that part works) Trying to create profile documents in a collection called "profiles" (using the collection name, not a UUID) The error happens even with ID.unique() generated IDs Key detail: I'm using the collection name "profiles" as the endpoint rather than a UUID collection ID, because I think that's what the newer Appwrite version wants. Code: const profile = await databases.createDocument( config.databaseId, config.profilesCollectionId, // This is "profiles" ID.unique(), // 20-char unique ID { authID: user.$id, username, displayName: displayName || "", email: user.email, } );

TL;DR
Issue: Developers facing "Document ID already exists" error when using ID.unique() in React Native/Expo to create profile documents in Appwrite. Solution: - Error is due to document IDs not being unique in the collection. - Use ID.unique() to generate a truly unique ID. - Consider using a UUID instead of the collection name as the endpoint. - Make sure the IDs generated are truly unique.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more