sveltejs / sveltejs/kit

SSR Only Routes

Open
#5,699 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the problem

In the fine-print of many API services, there is a clause to not re-distribute the data of the service API in another API. Sometimes parts of our apps will need to use these third-party data-sources. We may not necessarily have the license to distribute said data as json.

Another example: needing to show advertisement along with articles! We don't want someone to directly access our API and just read articles without our ability to monetize with ads! With full HTML render, ads will also be sent along.

Describe the proposed solution

SSR-only routes--routes without __data.json or that do not respond to application/json request headers, insure that we are not re-distributing API data in a way licensing does not allow.

Old school SSR. No API endpoints. Also, all endpoint point to this route should not try __data.json. With regard to prefetching, the browser does have a <link rel="prefetch" href="foo/bar" /> option, and perhaps a mouse over could get the browser to start a prefetch the HTML5 way for SSR only routes.

SSR-only routes living along side with smart hybrid rendered routes. It would be glorious.

Alternatives considered

Hand-crafting GET exports to fail on JSON requests use a proxy server to prevent JSON content going out from certain routes. Bleh.

Also needing to place sveltekit:reload on all inbound links as well. May even need to write custom logic to include HTML5 prefetching as well (ie, <link rel="prefetch" href="foo/bar" />). Tedious bookkeeping. Would be great if there was a compiler that could do this for us.

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 tracing how routes currently generate __data.json and handle application/json requests, then review the stated interactions with sveltekit:reload and HTML prefetching. Done would mean selected routes render only HTML, avoid JSON responses and data prefetching, and continue to work alongside hybrid-rendered routes.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.