I think API keys are used for admin purposes as far as i understood the docs, like when I want to list all the user or active session then upon requesting i was getting an error asking API key with specific scope set to it.
Secondly, how do we use the javascript SDK on the client in frameworks like astrojs
I haven't used AstroJS, so I'm not sure. But can't you use the plain JS that is provided in the docs?
cause Import or require works only on server side if I am not wrong, so do we have a sdk available in a cdn like vue or jquery is use to provide.
Nope I guess that is useful on Node js, it wont work in browser
um is that so? I use import statements in react and next all the time!
that's a different thing. There's the Server-side implementation, which is not the same as client.
exactly and react is build using either babel, vite or webpack or snowpack, which is were it gets handled
There is an SDK for nodejs, for server side integration. For JS, you should be able to use https://appwrite.io/docs/client/account
yepp you're right
On a plain js which loads on the client side wont work with this import or require syntax wont work
https://github.com/appwrite/playground-for-web Have you looked at this?
API keys should only be used server-side because they need to be kept secret. You can use a server SDK like the node one for server-side code.
client side, you should use the web sdk. import it whatever way works for you
exactly what I was thinking
I've never had any issues using import
statements in JS frameworks, and Astro should be able to handle that as well
I guess astro is little different when it comes to the client side code
ill learn on this an get back here
thanks for all your support @Steven and @safwan
Seems like it should do what I described
But you're the astro user here, not me. Try and lmk
my only recommendation is avoid server-side code if possible. it always makes things more complicated.
This is very new and still in the works, but: https://github.com/appwrite/demos-for-astro/blob/main/example-blog/src/lib/appwrite.ts
exactly as shown here, any javascript that is written in frontmatter (i.e between --- ---
) is executed at the build time and as claimed by astrojs, it wont ship any js on the client side which is the differentiatro of astro js hence if you still need to push any js on the client side then it needs to be added in the <script></script>
tags at the end of the astro component, which is shipped to client side to be specific its called inline js
Hope I was clear enough to explain.
Recommended threads
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...