-
Notifications
You must be signed in to change notification settings - Fork 478
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
Feature Request: Svelte and SvelteKit SDK #903
Comments
I second this. I've been a React dev since, but when I used Svelte/Kit -- I'm already using it right now and will for all my future projects. I also sent a feedback on this one :) . This would be awesome if added. 🔥 P.S. my biggest struggle (SSR issues, etc) right now is with Apollo (client and svelte-apollo). Although I've managed to make some tweaks, but it would be so nice if you can provide internal implementations. |
Do you have any links to existing Svelte SDKs similar to Nhost? It would be great for inspiration. |
This example no longer work for now :( |
I started thread for SvelteKit question: |
We don't have a svelte SDK planned for now but we can try to have an example app working soon. |
I am willing to assist on this if that is still required. As a new Nhost user, I may require some Nhost related handholding. Possible? |
Bump on this. An example monorepo with 2 apps: sveltekit and nhost would be nice. Because Sveltekit just went 1.0, and I see this blasphemy (at the end):
|
Hmm, to address this blasphemy:
|
Oh, nice that SvelteKit 1.0 was released. If anyone from our community wants to help us create a todo app with Nhost that would be great. It would be a perfect candidate for our |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@Stale bot taking matters into its own hands. This needs to be reopened and tracked . I am following the supabase example here https://github.com/huntabyte/sk-supabase-auth to see if it will work for nhost. Difference being supabase has helpers for sveltekit with which to create a serverside client (just like nhost has , but only for next.js) . I will feedback with the result here |
Hi @onehassan @nunopato, is there any plan to work on a SvelteKit SDK in the coming weeks/months? I saw that the task was assigned to Hassan, but not sure if there is any progress made. This was requested a year ago, and since then I think the interest in SvelteKit has only grown! Most of us who used React and tried Svelte are reluctant to go back to React. I tried to put something together reading the NextJS SDK code, and this and this, but I'm always stuck. Please don't make us use Supabase! :) |
Hi @gregoryforel, this is next on my list. Most likely we will be adding another package that provides helpers for user authentication in SvelteKit. All the other functionality will still be provided by our JS sdk. |
This is great news! Can't wait to try a working SvelteKit repo :) |
lol. Is Next.js so bad? Just curious |
NextJS is good, it would be too easy to deny it just because SvelteKit, which is IMO superior, came along. You simply write more code in React, and I have yet to find a kind of application that could not be done with SvelteKit but can with NextJS. |
@gregoryforel We have included a proper example for using Nhost with SvelteKit. Let us know if you have feedback/suggestions! |
https://github.com/nhost/nhost/blob/main/examples/sveltekit/src/lib/nhost-auth-sveltekit.js looks like an interesting adapter. Thanks for the example! (I'm still on the fence with Svelte itself) |
Thank you so much! |
This example confirms there is no way to use the nhost client server side like in sveltekit form actions running in +page.server.ts or am i missing something . I have tried implementing this for server side usage and with each use i get the error Even with start property in config set to true and calling start here
This example is just an SPA mode example: A simple svelte SPA app would have sufficed . I was expecting a server Client at the very least , the type you have in the next.js example |
The only thing the example confirms is that we are working on the examples. There are multitude of combinations of frameworks and mechanisms and we are doing our best to support and write examples for as many of them as possible. If any combination doesn't work for you it is best to report it, provide as much information as possible and be patient. |
@onehassan, @dbarrosop - Thank you for the example, it's a good starting point. What would be great is having nHost work the Sveltekit way with SSR (even though Sveltekit can do SPA and SSG). SSR is becoming the norm, it makes routing easier and has other perks included. I can't contribute directly on the nHost side because I simply lack the skills, however I put together a working example of SvelteKit and Pocketbase after watching a few tutorials, that I think would help you improve your example. I reckon this example is exactly what nHost users are expecting: server-side authentication, SSR, etc. I really don't want to come across as demanding, I just happen to think nHost is superior to Supabase, and once setup correctly, easier to use. I think nHost is lagging behind Supabase in terms of fully working starter kits that the community needs. Supabase is taking off and influencers start to make many examples, I'd love to see more of this with nHost. I understand that Supabase has a lof of funding though. IMO, it's key for nHost to nail the examples. Thanks in advance! |
@shiftlabs1 we've just released a new example project that showcases how to use the Nhost SDK running server-side with SvelteKit You can find it here Any questions or feedback are welcome as we want to improve this and make it easier for SvelteKit devs to use Nhost 🚀 |
@onehassan this server side example seems to require xstate , particularly the waitFor method. Since this is used within nhost, can that method alone be exposed, so we dont have to install xstate when our application does not make any use of it. (that method waitFor seems to be why its not been possible to instantaite the client serverside as it always returns null) |
Similar observation here , I am not sure i want to install xstate . what is the alternative here @onehassan ? |
We are going to add another method to our SDK that hides that part. Very soon you will be able to do |
That will be very helpful . |
@onehassan very cool work. I'm reading thru the code. Is it the case that your examples all execute the Nhost client via kit server (SSR)? The Nhost session is authenticated server-side, and the cookie is serialized to browser cookie 'nhostSession'? I'm just trying to wrap my head around it, because my app, i've done all the Nhost auth browser-side (CSR) using nhost.auth.onAuthStateChanged/onTokenChanged , and sometimes manually pass the JWT as a formData param if i want it on the SSR side. I want to use your technique for SSR, it would be simpler than manual passing. I may keep my login pages CSR but pass JWT to server load() your way. 🙂 |
@nohea The authentication in the example happens server-side (not SSR) except for when using a security (webauthn). Take a look at the webauthn signin page, you'll see that indeed we do the authentication on the client and then we save the session in a cookie that's accessible to the server. You can do the same thing but with an email and a password. After that you can use the |
The Svelte community is growing faster than you think.
More and more people are pouring down into the awesomeness of this framework.
It would really help if we could get an official SDK with well-written documentation on how to use it.
The text was updated successfully, but these errors were encountered: