Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

upgrade sveltekit to v1 #178

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

alexvdvalk
Copy link

Upgrade Sveltekit example template to Sveltekit V1.0.0 which was just released.

Copy link
Contributor

@azrikahar azrikahar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem to be more recent compared to #175, but would you mind taking a look to see whether there's any other changes over there that we can propagate over here?

Big disclaimer that I've not kept up with SvelteKit's changes, but one thing I do notice is it does looks like #175 is using the documented $env/static/private/$env/static/public approach to import environment variables, which is different than the older versions. Ref: https://kit.svelte.dev/docs/modules#$env-static-public.

Should we use that approach going forward as well? Assuming that's still the official v1 approach of course (unless the docs I'm looking at are not up to date).

@alexvdvalk
Copy link
Author

alexvdvalk commented Dec 16, 2022

Yes it would be best to use the new way of importing environmental variables. This ensures that the DB credentials are not accidentally bundled into the front end app.

I didn't want to change too many things in the first instance

I can ammend and resubmit.

@freekrai
Copy link
Contributor

@alexvdvalk I think it would be a good idea to the new way of importing env variables, outside of that everything looks good.

@alexvdvalk
Copy link
Author

I've cleaned up the environment variables setup so that it uses Sveltekits native management. Also updated the readme and dotenv dependency.

@emilyf
Copy link

emilyf commented Feb 17, 2023

This has been super helpful. I'm still running through this upgrade on my end, but a couple of things:

  • .env.example is missing PUBLIC_DIRECTUS_URL so all connections fail currently
  • It looks like project structure may need a little more cleanup, especially around client/server hooks structure aka https://kit.svelte.dev/docs/project-structure -- migrating to hooks.*.js. I'm still new to sveltekit1 so apologies for not submitting changes and just commenting. But it does look like src/lib/client.js would need to become src/hooks.client.js?
  • Again, still new to sveltekit, but should the example be combining the private/server and public/client variables in same file (src/lib/client.js) or should they be separated into hooks.client.js and hooks.server.js?

@alexvdvalk
Copy link
Author

alexvdvalk commented Feb 17, 2023

Thanks for your comment. I have replaced the SECRET_DIRECTUS_URL with PUBLIC_DIRECTUS_URL in the .env.example file. I also moved the client.js into a server folder as explained at https://kit.svelte.dev/docs/server-only-modules

I don't think hooks are requiered in this demo.

@emilyf
Copy link

emilyf commented Mar 23, 2023

For what it's worth, this is looking and running great on my end! Looking forward to the merge.

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

Successfully merging this pull request may close these issues.

4 participants