Svelte · Middle · Question 27 of 75

How do you mount a Svelte 5 component into the page manually?

import { mount } from "svelte";
import App from "./App.svelte";

const app = mount(App, { target: document.getElementById("app"), props: { name: "Ann" } });

Explanation

new Component() was the Svelte 4 API. For server-rendered HTML use hydrate instead of mount.

Further reading

Problem with a question

Svelte · Middle · question 27

Test yourself

Take the Svelte · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz