appwrite-svelte-kit-ssr Svelte Themes

Appwrite Svelte Kit Ssr

Appwrite + Svelte Kit with server-side rendering ⚡

🛎️ Appwrite + Svelte Kit (SSR)

This repository is an example of how an SSR can be achieved in Svelte Kit using Appwrite SDK.

The goal of this PoC was to create a website where users can sign in (and register), and view his profile (email and name). The main trick is that SSR needs to be working, so if the client disables JavaScript, his information (only accessible after authentication) will be displayed anyway.


The main SSR logic can be found in src/routes/index.js. As you can see, the trick is to take the correct cookie from Svelte Kit request.headers, and set it on Appwrite SDK client appwrite.headers. This way a request sent from the server (during SSR) proxies auth cookies properly, and gets a proper response of account.get().


🐌 Before implementing SSR

⚡ With SSR implemented

Auto-generated readme:

Everything you need to build a Svelte project, powered by create-svelte.

Creating a project

If you're seeing this, you've probably already done this step. Congrats!

# create a new project in the current directory
npm init svelte

# create a new project in my-app
npm init svelte my-app

Developing

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

Building

To create a production version of your app:

npm run build

You can preview the production build with npm run preview.

To deploy your app, you may need to install an adapter for your target environment.

Top categories

Loading Svelte Themes