0.0.7 • Published 23 days ago

svelte-amplify-adapter v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

Svelte-Amplify-Adapter

This is a simple adapter to enable SSR in SvelteKit 2 and aws-amplify 6.

Getting started

npm install svelte-amplify-adapter
import { parseAmplifyConfig } from "aws-amplify/utils";
import { getCurrentUser } from "aws-amplify/auth/server";
import awsConfig from "./awsConfig";
import type { ServerLoad } from "@sveltejs/kit";

import { runWithSvelteAmplifyServerContext } from "svelte-amplify-adapter";

export const load: ServerLoad = async ({ cookies }) => {
  const amplifyConfig = parseAmplifyConfig(awsConfig);

  return await runWithSvelteAmplifyServerContext(
    cookies,
    amplifyConfig,
    async (contextSpec) => {
      try {
        const user = await getCurrentUser(contextSpec);
        return { user };
      } catch (e) {
        return { user: undefined };
      }
    },
  );
};
0.1.0-next.3

23 days ago

0.1.0-next.0

23 days ago

0.1.0-next.1

23 days ago

0.1.0-next.2

23 days ago

0.0.7

4 months ago

0.0.6

4 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago