Skip to content

Commit

Permalink
Upadte example and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelmund committed Feb 17, 2022
1 parent 5068919 commit 3e157fd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Check out, [Svemix](https://github.com/svemix/svemix) if you want to have a better developer experience using **SvelteKit**. Svemix can be seen as an full stack addition to **Kit**. It let's you write server side code inside .svelte files, has session handling on the next level with auto client session updates, loaders and actions that run on the server and even working with javascript disabled, also provides you with meta/SEO handling.

---
---

**This [SvelteKit](https://kit.svelte.dev) backend utility** allows you to create a session to be stored in the browser cookies via a encrypted seal. This provides strong client/"stateless" sessions.

Expand Down Expand Up @@ -47,6 +47,32 @@ const config = {
};
```

Update your `app.d.ts` file to look something like:

```ts
/// <reference types="@sveltejs/kit" />

interface SessionData {
// Your session data
views: number;
}

// See https://kit.svelte.dev/docs#typescript
// for information about these interfaces
declare namespace App {
interface Locals {
session: import("svelte-kit-cookie-session").Session<SessionData>;
cookies: Record<string, string>; // all parsed cookies are automatically set from handleSession to avoid overhead
}

interface Platform {}

interface Session extends SessionData {}

interface Stuff {}
}
```

## Usage

You can find an example implementation here [Example](/example).
Expand Down
8 changes: 4 additions & 4 deletions example/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
1 change: 0 additions & 1 deletion example/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const handle = handleSession(
secret: "A_VERY_SECRET_SECRET_32_CHARS_LONG",
},
async function ({ event, resolve }) {

const response = await resolve(event, {
transformPage: ({ html }) => {
const theme = event.locals.session.data?.theme ?? "light";
Expand Down

0 comments on commit 3e157fd

Please sign in to comment.