Skip to content

Instantly share code, notes, and snippets.

@dabit3
Last active December 30, 2020 08:20
Show Gist options
  • Save dabit3/f1895091d9536235704dcf9d1c9a7d7e to your computer and use it in GitHub Desktop.
Save dabit3/f1895091d9536235704dcf9d1c9a7d7e to your computer and use it in GitHub Desktop.
Enabling SSR support in Amplify
// Enable SSR support in Amplify app
Amplify.configure({ ...config, ssr: true })
// Library usage in SSR or API routes
import { withSSRContext } from 'aws-amplify'
const { Auth, API } = withSSRContext({ req })
// Get user session
const user = await Auth.currentAuthenticatedUser()
// Make authenticated GraphQL API call
const data = await API.graphql({ query: someQuery })
// Make authenticated REST API call
const data = await API.get('myapi', '/posts')
@mtliendo
Copy link

slight typo on line 12. graphqlk graphql

@dabit3
Copy link
Author

dabit3 commented Oct 18, 2020

Thanks @mtliendo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment