---
title: "How Bun supports V8 APIs without using V8 (part 1)"
description: "Bun, which runs on JavaScriptCore, implements a growing subset of V8's C++ embedding API so Node.js native modules like cpu-features load without V8."
url: "https://swe.quest/articles/how-bun-supports-v8-apis-without-using-v8-part-1-ff8148b61cb465d8"
canonical: "https://bun.com/blog/how-bun-supports-v8-apis-without-using-v8-part-1"
source: "Bun"
published: "2024-09-30"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 19
tags: ["runtimes","c-cpp","javascript","memory-management"]
---

# How Bun supports V8 APIs without using V8 (part 1)

A post on [Bun](https://swe.quest/sources/bun.md), published 2024-09-30, 19 min read, Deep dive. Original: [https://bun.com/blog/how-bun-supports-v8-apis-without-using-v8-part-1](https://bun.com/blog/how-bun-supports-v8-apis-without-using-v8-part-1)

## Summary

Bun, which runs on JavaScriptCore, implements a growing subset of V8's C++ embedding API so Node.js native modules like cpu-features load without V8. The post contrasts JSC and V8 value representation, calling conventions, isolates/contexts and handle-based lifetimes. It then shows why an initial approach of reinterpreting JSC's 8-byte JSValue as V8's Local\<T\> pointer failed. V8's inline header functions such as Object::GetInternalField dereference Local pointers and read map and instance-type fields at fixed offsets, so Bun's in-memory layouts must match what V8's compiled-in inline code expects.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)

## Prerequisites

- C++ pointers and ABI basics ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- JavaScript engine concepts ([easy posts on Runtimes & VMs](https://swe.quest/tags/runtimes.md?difficulty=easy))
- Node.js native addons ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

Bun, V8, JavaScriptCore, Node-API, cpu-features, Node.js

## Related posts

- [How Bun supports V8 APIs without using V8 (part 2)](https://swe.quest/articles/how-bun-supports-v8-apis-without-using-v8-part-2-d765ff746fe7a86a.md): Bun · 2024-11-05 · Hard · 18 min read · Runtimes & VMs, JavaScript, C & C++, Memory management
  Bun emulates V8's memory layout on top of JavaScriptCore so that precompiled native addons, which inline V8 functions assuming specific pointer layouts, keep working.
- [V8 release v6.9 · V8](https://swe.quest/articles/v8-release-v6-9-v8-d0efd26e2594b2df.md): V8 · 2018-08-07 · Easy · 4 min read · Runtimes & VMs, JavaScript, Memory management, WebAssembly, Compilers
  V8 v6.9 embeds built-in functions directly into the binary on x64, so all Isolates share one copy instead of each holding up to 700 KB on its own heap.
- [Announcing Stable V8 Bindings for Rust](https://swe.quest/articles/announcing-stable-v8-bindings-for-rust-01bc1bc22c1cbdef.md): Deno · 2024-09-24 · Medium · 4 min read · Rust, Runtimes & VMs, JavaScript, Memory safety
  Rusty V8, Deno's zero-overhead Rust bindings to V8's C++ API, is now stable and skips 1.0 to align with Chrome versioning, starting at 129.0.0.
- [Bun v0.7.0](https://swe.quest/articles/bun-v0-7-0-d3096f46f4bdb50f.md): Bun · 2023-07-21 · Medium · 10 min read · JavaScript, Runtimes & VMs, Concurrency
  Bun v0.7.0 focuses on Node.js compatibility: it can now run \`vite dev\` (experimentally, via \`bun --bun\` to override the node shebang), supports Web \`Worker\` threads with \`postMessage\` and \`structuredClone()\`, and implements \`AsyncLocalStorage\` from \`node:async\_hooks\` as a step toward Next.js support.
- [Bun v0.3.0](https://swe.quest/articles/bun-v0-3-0-ce34b4df06ef614a.md): Bun · 2022-12-07 · Medium · 8 min read · JavaScript, Runtimes & VMs, Performance engineering
  Bun v0.3.0 focuses on stability and Node.js/Web API compatibility, cutting memory use 3-5x under load by scheduling garbage collection in coordination with the event loop and speeding up TextEncoder.encodeInto() 3x via simdutf.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
