Home / Function/ syncAstroEnv() — astro Function Reference

syncAstroEnv() — astro Function Reference

Architecture documentation for the syncAstroEnv() function in sync.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  462d90fc_4cfb_0cfc_b6e8_de672a2ab258["syncAstroEnv()"]
  f73e3658_46d2_0dd8_b1e9_ceec9707ddd6["sync.ts"]
  462d90fc_4cfb_0cfc_b6e8_de672a2ab258 -->|defined in| f73e3658_46d2_0dd8_b1e9_ceec9707ddd6
  style 462d90fc_4cfb_0cfc_b6e8_de672a2ab258 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/env/sync.ts lines 5–34

export function syncAstroEnv(settings: AstroSettings): void {
	let client = '';
	let server = '';

	for (const [key, options] of Object.entries(settings.config.env.schema)) {
		const str = `	export const ${key}: ${getEnvFieldType(options)};	\n`;
		if (options.context === 'client') {
			client += str;
		} else {
			server += str;
		}
	}

	let content = '';
	if (client !== '') {
		content = `declare module 'astro:env/client' {
${client}}`;
	}
	if (server !== '') {
		content += `declare module 'astro:env/server' {
${server}}`;
	}

	if (content !== '') {
		settings.injectedTypes.push({
			filename: ENV_TYPES_FILE,
			content,
		});
	}
}

Domain

Subdomains

Frequently Asked Questions

What does syncAstroEnv() do?
syncAstroEnv() is a function in the astro codebase, defined in packages/astro/src/env/sync.ts.
Where is syncAstroEnv() defined?
syncAstroEnv() is defined in packages/astro/src/env/sync.ts at line 5.

Analyze Your Own Codebase

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

Try Supermodel Free