> For the complete documentation index, see [llms.txt](https://divine.qibergames.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://divine.qibergames.com/advanced-usage/dependency-hooks.md).

# Dependency hooks

You may use dependency hooks to modify the instances when they are requested from the container. Hooks can modify the properties of the dependency, or even replace the instance with another one.

<figure><img src="https://3376145113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F40YFNvjPqSybFHd4PSEP%2Fuploads%2FmKLWgdEpRGM3WAdpJxBC%2Fimage.png?alt=media&amp;token=9f83a2b5-d670-468d-b80f-596c4b4b4e85" alt=""><figcaption></figcaption></figure>

```java
@Service
class MyService {
    private int value = 5;
}

void useHooks() {
    Container.addHook("MY_HOOK", (service, container) -> {
        // override the default value of `5` to `10`
        service.value = 10;
        return service;
    });
    
    MyService service = Container.get(MyService.class);
    assert service.value == 10;
}
```
