sveltejs / sveltejs/kit

Web Components Embedding Mode

Open
#11,430 0 comments 3 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

The unfortunate reality is that sometimes I need to do work in non-SvelteKit environments, e.g. WordPress. Ideally, I would like to get the benefits of Svelte and SvelteKit, but be able to deploy to such distasteful environments without mucking about with them too much.

Describe the proposed solution

What if SvelteKit's adapter API had a web component based embedding mode?

There are several ways this could work, but here is one idea:

  • The SvelteKit app still gets deployed with usual adapters (e.g. Vercel, Netlify, Node, etc)
  • However, the app is modified to act as a backend for deploying web components elsewhere
  • +page.svelte routes get compiled to web components
  • The web components may be served through an automatically generated endpoint, or packaged using svelte-package
  • +page.js/ts load mechanisms still work, but are compiled to endpoints why serve the corresponding web components with data.
  • An automatically generated docs page is served, providing snippets for CORS config, and - eventually perhaps - web component usage snippets.

There would obviously be some limitations, e.g. SSR is excluded in this mode; I am not familiar enough with the nuances of SvelteKit to know what they would be.

Alternatives considered

Setting this up manually, probably with a monorepo including one package for the web components, and another for the backend.

Importance

would make my life easier

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 reviewing SvelteKit's adapter API and the mentioned +page.svelte and +page.js/ts route entry points, then examine how svelte-package and generated endpoints could support embedding. The proposal needs an agreed design for web-component compilation, data loading, CORS guidance, and SSR limitations before implementation can be considered done.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
backend, frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.