0Pricing
Sveltejs Academy · Lesson

Declaring Props with export let

Expose component properties to parent components using the export keyword.

Declaring Props with export let is a free Sveltejs Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Sveltejs Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Props Are Exports

To declare a prop, write export let name in the component script. The keyword export exposes it to parents.

<script>
  export let name;
</script>

<p>Hello {name}!</p>

Multiple Props

List as many props as your component needs.

<script>
  export let title;
  export let count;
  export let onClick;
</script>

Typed Props

Add types with TypeScript for safety and editor support.

<script lang="ts">
  export let count: number;
  export let label: string;
</script>

Why export

The export keyword in script context is borrowed from ES modules but means "expose to parent" in Svelte.

Required vs Optional

Props without a default value are required. Provide a default to make them optional.

export let title = "Untitled";

Read-Only Convention

Treat props as read-only inputs. Mutating them is technically allowed but breaks one-way data flow.

Reactive Props

Props are reactive: when the parent passes a new value, the component re-renders automatically.

Default Functions

Default values can be functions or computed expressions.

export let onClick = () => {};

Boolean Props

For boolean props, providing the attribute without a value is true.

<MyComp disabled />

Aliased Props

If the prop name is a reserved word like class, you can rename internally.

let className;
export { className as class };

Renamed Aliases

The alias pattern lets you accept HTML-friendly names while keeping JS-valid identifiers inside.

Quick Check

How do you declare a prop?

Recap

Props are declared with export let, can be typed, have defaults, and are reactive when the parent updates them.

Frequently asked questions

Is the “Declaring Props with export let” lesson free?

Yes — the full text of “Declaring Props with export let” is free to read here on the web, and the Sveltejs Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Sveltejs Academy course, upgrade to CoddyKit PRO.

What will I learn in “Declaring Props with export let”?

Expose component properties to parent components using the export keyword. You practise Sveltejs Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Sveltejs Academy?

No prior experience is required. Sveltejs Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Declaring Props with export let” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Sveltejs Academy lesson?

Yes. Every Sveltejs Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Declaring Props with export let
  2. Passing Props from Parent
  3. Default Prop Values
  4. Forwarding Props with $$props and $$restProps
← Back to Sveltejs Academy