Appwrite is an open source and self-hosted backend service platform that aims to simplify common and complex tasks required to build modern web and mobile applications. Designed as an open source alternative to Firebase, Appwrite offers developers a wide range of features such as user authentication, database management, file storage, cloud functions and real-time communication. These features allow developers to build faster and more secure applications, while greatly streamlining the back-end development process.
SvelteKit can be described as an application framework (or “metaframework”) based on Svelte. While Svelte is a lightweight and performance-oriented UI framework used to build user interface components, SvelteKit is a tool that helps you build modern web applications using these components. SvelteKit provides developers with support for different rendering techniques such as server-side rendering (SSR), client-side rendering (CSR), static site generation (SSG) and single-page apps (SPA), allowing you to optimize the performance and SEO features of your apps.
First we create a SvelteKit project. I will use bun to build this project, you can also use npm or pnpm.
Now we have SvelteKit files. Now we need to create a new project via Appwrite.
After creating the project, you need to click on “API key” in this section.
Here you need to set the name of your API key and the expiration date. It is recommended to set the expiration date to “Never”.
After making those settings, you need to select all scopes values here.
Finally, you need to go to the project settings section and copy the “Project ID” part.
That was our Appwrite setup, now let's move on to using it on the project.
We will first need to download the Appwrite module to use it in the project. You can include it in the project by typing bun i appwrite
command.
After downloading the module, you should create a file named db.ts
under src/lib
.
To add the import.meta.env.VITE_APP_PROJECT_ID
part here, you must first open an .env
file and enter a value named VITE_APP_PROJECT_ID
. This value will be the “Project ID” value you get from Appwrite.
Now that we have prepared this .env
file, we need to prepare register, login and profile files.
First of all we need to prepare the register
file because first of all the user needs to create an account. We need to open a file named src/routes/register/+page.svelte
and add the following codes into it.
Now that we have done the registration system, the profile part is next. Open a file named src/routes/login/+page.svelte
and write the following code in it.
The last thing left to do is the profile part, which we will do in src/routes/profile/+page.svelte
.
That's it, now your project is ready. You can complete your project by adding more on top of it. You can view the source code by clicking this link.