Skip to content
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

Sveltekit flags enhancements #75

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Conversation

dummdidumm
Copy link

@dummdidumm dummdidumm commented Feb 23, 2025

This enhances the SvelteKit adapter in several ways:

  • use $env/dynamic/private, which means people don't have to pass FLAGS_SECRET manually anymore. This means Vite will have to compile this in the context of the app, but that's not a problem and should happen automatically
  • allow a created flag to be called oustide of the lifecycle of the handle hook, with a request object being the key for deduplication etc. This allows it to be called from e.g. edge middleware
  • add support for identifiers, including deduplicating their calls. This is achieved by adding a Map onto the context in which flags run, with the identify function being the key. That means calls are deduplicated automatically as soon as you share a stable reference to the function across flags
  • add createPrecomputedFlags which is a function for generating permutations, then precomputing one and retrieving it. It's different to the Next.js API because it does not need you to pass the array of flags everywhere, instead you define which flags belong to which route param once and then access methods on the returned object. Using it feels a bit nicer than the Next.js approach IMO, but open to suggestions model precompute API closely after Next.js to align

This needs sveltejs/kit#13477 to land first, so that you can actually precompute something in middleware, and it would be good to also enhance the example SvelteKit app as well then. Makes use of the new async reroute feature in SvelteKit.

Copy link

vercel bot commented Feb 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flags-sdk-snippets ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 10:35am
flags-sdk-sveltekit-snippets ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 10:35am
shirt-shop ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 10:35am
summer-sale ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 12, 2025 10:35am

@dummdidumm
Copy link
Author

Ready for review - let me know if the examples need tweaking / should be aligned in specific ways with the Next examples.

Also, is there anything with regards to the docs we should be updating / adjusting at the same time?

Copy link

socket-security bot commented Mar 11, 2025

New, updated, and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@sveltejs/[email protected]4.0.0 None +1 85 kB conduitry, dominik_g, rich_harris, ...1 more
npm/@sveltejs/[email protected] Transitive: filesystem +14 1.66 MB conduitry, dominik_g, rich_harris, ...1 more
npm/[email protected]4.1.5 Transitive: environment, filesystem +10 5.59 MB dummdidumm, orta, svelte-language-tools-deploy
npm/[email protected]5.22.6 None +17 4.6 MB conduitry, rich_harris, svelte-admin

View full report↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant