-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow embedding a sveltekit page as a widget in a third party website #13638
base: main
Are you sure you want to change the base?
Conversation
|
Implements #13589
This (draft) PR brings the possibility to embed a sveltekit page as a widget in a third party website in a convenient manner.
It's just a proof-of-concept, showing how easy (or how hard) it is to implement.
How it works
Any +page.server.js can export an
embed
function and return an object containing a target (a dom selector)In this case, the page can be embedded by including this script
What works
How to test
I added a test app in
kit/packages/kit/test/apps/embedded-widget
Stackblitz
pnpm install cd packages/kit/test/apps/embedded-widget/ pnpm run dev
Todo
Extra details
The code adds the embed script origin to the app base
The code also uses the
document.currentScript.src
instead of thelocation
to determine if a url is external to the widget. There might be other places where this should be done and I've missed it.Feel free to test, I would love to know what you think about this and if it's a good feature
Cheers
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits