sveltejs / sveltejs/kit

Protected pre-rendered routes

Open
#11,700 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the problem

I have an expensive static page which also happens to be a protected route.

I would love to prerender the page, but then it is not handled by SvelteKit.

Requests for static assets — which includes pages that were already prerendered — are not handled by SvelteKit.

https://kit.svelte.dev/docs/hooks#server-hooks-handle

Describe the proposed solution
  1. Add another page option in +page|layout.server.ts such as server: true.
  2. Add another value for the current prerender option such as protected.
  3. (Breaking) Convert the page prerender option into an object?
type Prerender = { enabled: boolean; protected: boolean };

https://kit.svelte.dev/docs/page-options#prerender

I am sure there are other usage then protected, but it seemed the most intuitive.

Alternatives considered

No response

Importance

would make my life easier

Additional Information

No response

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 by reading the page options for +page|layout.server.ts and the prerender documentation linked in the issue, then trace how pre-rendered pages are excluded from server hooks. Define and implement a supported way for a pre-rendered protected route to retain server handling, including any option or breaking-change implications, and verify the behavior with the relevant project tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authentication, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.