Declaring props with export let in Svelte
📖 Scenario: You are building a simple Svelte component that shows a greeting message. The message should come from outside the component, so you need to declare a prop to receive it.
🎯 Goal: Create a Svelte component that declares a prop called greeting using export let and displays it inside a <h1> tag.
📋 What You'll Learn
Declare a prop named
greeting using export letUse the
greeting prop inside an <h1> tagThe component should render the greeting text passed as a prop
💡 Why This Matters
🌍 Real World
Props let you create reusable components that can show different data depending on where they are used, like greeting messages, user profiles, or product cards.
💼 Career
Understanding how to declare and use props is essential for building interactive and modular UI components in Svelte, a popular modern frontend framework.
Progress0 / 4 steps