Skip to content

Commit

Permalink
SvelteKit 2 update.
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscoheat committed Dec 14, 2023
1 parent 5d2afa7 commit fa6f2e0
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 139 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ Import `getFlash` in a layout or page component to display the flash message. `g

### Server-side

To send a flash message from the server, import `redirect` from `sveltekit-flash-message/server` and throw it, as in [load](https://kit.svelte.dev/docs/load#redirects) and [form actions](https://kit.svelte.dev/docs/form-actions#anatomy-of-an-action-redirects).
To send a flash message from the server, import `redirect` from `sveltekit-flash-message/server` and use it in [load functions](https://kit.svelte.dev/docs/load#redirects) and [form actions](https://kit.svelte.dev/docs/form-actions#anatomy-of-an-action-redirects).

**Note:** With SvelteKit 2, you don't need to [throw the redirect anymore](https://kit.svelte.dev/docs/migrating-to-sveltekit-2#redirect-and-error-are-no-longer-thrown-by-you), just call `redirect`.

```typescript
import { redirect } from 'sveltekit-flash-message/server'
Expand Down Expand Up @@ -249,7 +251,7 @@ flash.subscribe(($flash) => {

## Flash message options

In a top-level component, most likely a `+layout.svelte` file, when you call `getFlash` for a `page`, you can specify options. **Note** that options can only be set the first time you call `getFlash` for a certain page/layout, usually in the top-level component. Subsequent calls to `getFlash` in components below cannot have any options. (See the first call to it as a kind of constructor.)
In a top-level component, most likely a `+layout.svelte` file, you can specify options for `getFlash`. **Note** that options can only be set the first time you call `getFlash` for a certain page/layout, usually in the top-level component. Subsequent calls to `getFlash` in components below cannot have any options. (See the first call to it as a kind of constructor.)

```typescript
const flash = getFlash(page, {
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
"format": "prettier --plugin-search-dir . --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.1.1",
"@sveltejs/kit": "^1.30.3",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/package": "^2.2.3",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.55.0",
Expand All @@ -47,7 +48,7 @@
"svelte-preprocess": "^5.1.2",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^4.5.1"
"vite": "^5.0.9"
},
"peerDependencies": {
"@sveltejs/kit": "1.x || 2.x",
Expand Down Expand Up @@ -84,4 +85,4 @@
]
}
}
}
}
Loading

0 comments on commit fa6f2e0

Please sign in to comment.