sveltejs / sveltejs/kit

Different `App.PageData` for each `layout.svelte`

Open
#13,592 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

types / typescript
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

It would be nice if I could set App.PageData different for each layout, and then the pages inside the layout should be forced to extend that interface.

For example, a website may have a "general" layout and an "administrator" layout. I want to set the title on the layout based on the current page data. But inside the admin portal, it is different.

Describe the proposed solution

Have a way to declare the interface inside layout.svelte instead of app.d.ts

Alternatives considered

No response

Importance

nice to have

Additional Information

Related to #11779 because if I can't enforce it, it's not very useful.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with app.d.ts and layout.svelte, then read the related discussion in issue #11779. Determine how layout-specific interfaces could constrain pages inside each layout; the work is done when separate layouts can declare distinct App.PageData types and descendant pages are checked against them.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.