Skip to content

Commit

Permalink
Add flash message support to layout server and client
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspresume committed Jan 25, 2024
1 parent 027246a commit 2224029
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { LayoutServerLoad } from './$types';

import { loadFlash } from 'sveltekit-flash-message/server';
import { superValidate } from 'sveltekit-superforms/server';

import { createBaseMetaTags } from '$lib/utils/metaTags';

import { FeedbackValidationSchema } from '$validations/feedbackValidationSchema';

export const load = (async ({ url }) => {
export const load = loadFlash(async ({ url }) => {
const baseMetaTags = createBaseMetaTags(url);

return {
Expand Down
10 changes: 10 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import { dev } from '$app/environment';
import { page } from '$app/stores';
import { getFlash } from 'sveltekit-flash-message';
import { toast } from 'svelte-sonner';
import { inject } from '@vercel/analytics';
import { Toaster } from '$components/ui/sonner';
Expand All @@ -18,6 +22,12 @@
export let data;
const flash = getFlash(page);
$: if ($flash) {
toast.info($flash.message);
}
inject({ mode: dev ? 'development' : 'production' });
setupViewTransition();
Expand Down

0 comments on commit 2224029

Please sign in to comment.