I want to go from CRA to nextjs but I am having troubles integrating AWS Amplify authentication. The amplify login form does show up but when trying to sign in it gives me the following error:
Error
[ERROR] 40:38.8 AuthError -
Error: Amplify has not been configured correctly.
The configuration object is missing required auth properties.
This error is typically caused by one of the following scenarios:
1. Did you run `amplify push` after adding auth via `amplify add auth`?
See https://aws-amplify.github.io/docs/js/authentication#amplify-project-setup for more information
2. This could also be caused by multiple conflicting versions of amplify packages, see (https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js) for help upgrading Amplify packages.
src/app/layout.tsx
import './globals.css'
import { Inter } from 'next/font/google'
import '@aws-amplify/ui-react/styles.css';
import { Amplify } from "aws-amplify";
import awsExports from "../aws-exports";
Amplify.configure({ ...awsExports, ssr: true });
const inter = Inter({ subsets: ['latin'] })
export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
)
}
src/app/page.tsx
"use client"
import { withAuthenticator } from "@aws-amplify/ui-react";
function Home() {
return (
<div>
<h1>Home</h1>
</div>
)
}
export default withAuthenticator(Home);
- Tried a fresh install of NextJS
amplify pull
aws-exports
to the client? Just trying out thisapp
directory approach in place of thepages
dir when it comes to nextJS 13. – Clearstory