We are thrilled to announce that we have added time-to-live (TTL) support for both Firestore Native and Datastore mode!
Common use cases
- Garbage collection. TTL can be handy if you have data that has a well-defined lifecycle for a document.
- Support time relevant features natively. You can rely on TTLs if you want to build features relying on ephemeral data.
- Security and privacy compliance. There are some regulations that require data retention for no longer than a certain time. You will have the flexibility to configure different expiration at the document level, which can help you meet the requirements from varying sources.
Example walkthrough
Sounds like a good candidate for your application? Let’s walk through an example to see how it works from end to end. The example below uses documents and collections, but it works similarly for entities and kinds.
Assume you have a database that saves lots of documents in collection Chats and some of them will be useless at some point in the future.



Special thanks to Minh Nguyen, Lead Product Manager for Firestore, and Joseph Batchik, Software Engineer for Firestore, for contributing to this post.
By: Hansi Mou (Software Engineer, Firestore) and Josué Urbina (Software Engineer, Firestore)
Source: Google Cloud Blog