You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

svelte-amplify-adapter

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-amplify-adapter

Adapter to enable aws-amplify SSR in SvelteKit

0.0.7
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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 };
      }
    },
  );
};

Keywords

svelte

FAQs

Package last updated on 14 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts