withastro/astro · error · Error

Could not find server component path

Error message

Could not find server component path

What it means

ServerIslandComponent.getComponentPath reads the internal prop server:component-path, which the compiler injects when compiling a server-island usage (experimental server islands). The prop tells the island host which server route/file to fetch its content from. If it is absent, the host cannot resolve its component and throws this plain Error.

Source

Thrown at packages/astro/src/runtime/server/render/server-islands.ts:99

		destination.write(`<!--${SERVER_ISLAND_START}-->`);
		// Render the slots
		for (const name in this.slots) {
			if (name === 'fallback') {
				await renderChild(destination, this.slots.fallback(this.result));
			}
		}
		destination.write(
			`<script type="module" data-astro-rerun data-island-id="${hostId}">${islandContent}</script>`,
		);
	}

	getComponentPath(): string {
		if (this.componentPath) {
			return this.componentPath;
		}
		const componentPath = this.props['server:component-path'];
		if (!componentPath) {
			throw new Error(`Could not find server component path`);
		}
		this.componentPath = componentPath;
		return componentPath;
	}

	getComponentExport(): string {
		if (this.componentExport) {
			return this.componentExport;
		}
		const componentExport = this.props['server:component-export'];
		if (!componentExport) {
			throw new Error(`Could not find server component export`);
		}
		this.componentExport = componentExport;
		return componentExport;
	}

	async getHostId() {

View on GitHub (pinned to 52e6c34790)

Solutions

  1. Reinstall/align dependencies so astro and @astrojs/compiler come from the same release
  2. Use the documented server islands API rather than constructing ServerIslandComponent directly
  3. Disable plugins that transform component props/attributes and rebuild
Defensive patterns

Strategy: validation

Validate before calling

// if you must construct island hosts manually, supply the internal props
const island = new ServerIslandComponent(result, {
  'server:component-path': '/src/components/Widget.astro',
  'server:component-export': 'default',
}, slots, 'Widget');

Type guard

function hasServerIslandProps(props: Record<string, unknown>): boolean {
  return typeof props['server:component-path'] === 'string';
}

Prevention

When it happens

Trigger: Constructing or rendering ServerIslandComponent manually without the internal props; a build where the compiler transform that injects server:component-path did not run (astro/@astrojs/compiler version skew, or a plugin stripping props); using the internal class instead of the documented server islands API.

Common situations: Mismatched astro and @astrojs/compiler versions after a partial upgrade; integrations or custom renderers re-instantiating island hosts; developers poking at the internal ServerIslandComponent export.

Related errors


AI-assisted analysis of withastro/astro@52e6c34790 (2026-08-18). Data as JSON: /api/errors/1e637524d39dcbff. Report an issue: GitHub.