<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@firebase/database](./database.md) &gt; [onChildRemoved](./database.onchildremoved_1.md)

## onChildRemoved() function

Listens for data changes at a particular location.

This is the primary way to read data from a Database. Your callback will be triggered for the initial data and again whenever the data changes. Invoke the returned unsubscribe callback to stop receiving updates. See [Retrieve Data on the Web](https://firebase.google.com/docs/database/web/retrieve-data) for more details.

An `onChildRemoved` event will be triggered once every time a child is removed. The `DataSnapshot` passed into the callback will be the old data for the child that was removed. A child will get removed when either:

- a client explicitly calls `remove()` on that child or one of its ancestors - a client calls `set(null)` on that child or one of its ancestors - that child has all of its children removed - there is a query in effect which now filters out the child (because it's sort order changed or the max limit was hit)

<b>Signature:</b>

```typescript
export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  query | [Query](./database.query.md) | The query to run. |
|  callback | (snapshot: [DataSnapshot](./database.datasnapshot.md)<!-- -->) =&gt; unknown | A callback that fires when the specified event occurs. The callback will be passed a DataSnapshot and a string containing the key of the previous child, by sort order, or <code>null</code> if it is the first child. |
|  options | [ListenOptions](./database.listenoptions.md) | An object that can be used to configure <code>onlyOnce</code>, which then removes the listener after its first invocation. |

<b>Returns:</b>

[Unsubscribe](./database.unsubscribe.md)

A function that can be invoked to remove the listener.

