0.0.7 • Published 1 year ago

svelte-amplify-adapter v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

0.1.0-next.0

1 year ago

0.1.0-next.1

1 year ago

0.1.0-next.2

1 year ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago