Home / Function/ ctx() — svelte Function Reference

ctx() — svelte Function Reference

Architecture documentation for the ctx() function in renderer.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  67e574ef_12ff_a34a_1e29_df1a6a01a768["ctx()"]
  ce85d155_9f13_f67c_9824_407161a6c2c7["Renderer"]
  67e574ef_12ff_a34a_1e29_df1a6a01a768 -->|defined in| ce85d155_9f13_f67c_9824_407161a6c2c7
  996c7fa5_2d99_0bb8_8ca5_ceef284d88cf["get_render_context()"]
  67e574ef_12ff_a34a_1e29_df1a6a01a768 -->|calls| 996c7fa5_2d99_0bb8_8ca5_ceef284d88cf
  8adf5be1_6f3f_bdc7_434e_73751503e727["unresolved_hydratable()"]
  67e574ef_12ff_a34a_1e29_df1a6a01a768 -->|calls| 8adf5be1_6f3f_bdc7_434e_73751503e727
  6f1eae94_35bd_e5bc_d962_31f3ce608951["push()"]
  67e574ef_12ff_a34a_1e29_df1a6a01a768 -->|calls| 6f1eae94_35bd_e5bc_d962_31f3ce608951
  a6460863_04d4_2187_b17f_03fcb0b078b2["sha256()"]
  67e574ef_12ff_a34a_1e29_df1a6a01a768 -->|calls| a6460863_04d4_2187_b17f_03fcb0b078b2
  style 67e574ef_12ff_a34a_1e29_df1a6a01a768 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/internal/server/renderer.js lines 598–613

	async #collect_hydratables() {
		const ctx = get_render_context().hydratable;

		for (const [_, key] of ctx.unresolved_promises) {
			// this is a problem -- it means we've finished the render but we're still waiting on a promise to resolve so we can
			// serialize it, so we're blocking the response on useless content.
			w.unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? '<missing stack trace>');
		}

		for (const comparison of ctx.comparisons) {
			// these reject if there's a mismatch
			await comparison;
		}

		return await this.#hydratable_block(ctx);
	}

Domain

Subdomains

Frequently Asked Questions

What does ctx() do?
ctx() is a function in the svelte codebase, defined in packages/svelte/src/internal/server/renderer.js.
Where is ctx() defined?
ctx() is defined in packages/svelte/src/internal/server/renderer.js at line 598.
What does ctx() call?
ctx() calls 4 function(s): get_render_context, push, sha256, unresolved_hydratable.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free