API Reference

@unjs/defu

Deep-merge utility for configuration objects, assigning source properties onto target without overwriting existing values.

Official Documentation ↗
CompatibilityThis documentation covers version v6.1. Check the official docs for the latest API surface.

Installation

npmnpm install defu

Methods

@unjs/defu is deep-merge utility for configuration objects, assigning source properties onto target without overwriting existing values. This page documents the core methods, installation, and common usage patterns for the current stable release.

Installation

Install @unjs/defu with your preferred package manager using the command shown in the frontmatter. The package is published to the npm registry and ships with TypeScript types where applicable.

Core methods

The methods listed in the frontmatter cover the primary API surface. Each signature reflects the v6.1 release. Consult the official documentation linked in sourceUrl for advanced options, edge cases, and breaking changes between major versions.

Frequently asked questions

The faq section in the frontmatter answers the most common questions about @unjs/defu, including comparisons with alternatives, configuration tips, and runtime requirements. If your question is not covered, check the source URL for the full guide.

Security

Official security statements captured from the package documentation:

API reference evidence

Fetched from official sources on 2026-11-08T20:10:00+08:00 via WebFetch https://raw.githubusercontent.com/unjs/defu/main/src/defu.ts;WebFetch https://raw.githubusercontent.com/unjs/defu/main/src/types.ts.

FAQ

How is it different from Object.assign?
defu deep-merges nested objects and does not overwrite existing values; Object.assign is shallow and overwrites.
Is it recursive?
Yes. Nested objects are merged recursively; arrays are replaced, not concatenated.
Is it zero-dependency?
Yes. It is a single utility with no dependencies.