Set up fullstack project
To set up the project, you'll first create a new Next.js app with Create Next App, a simple CLI tool that enables you to quickly start building a new Next.js application, with everything set up for you. You'll then add Amplify and initialize a new project.
From your projects directory, run the following commands:
1npm create next-app@14 -- next-amplified --ts --no-eslint --src-dir --import-alias '@/*' --no-tailwind --app2cd next-amplified
This command will bootstrap the project with the following options:
- App Router
- No ESLint
- With the
- No Tailwind CSS
- imports aliased to
Now that you're in the root of the project, you can run the app by using the following command:
1npm run dev
This runs a development server and allows us to see the output generated by the build, you can see the running app by navigating to \http://localhost:3000>.
Now that you have a running app, it's time to set up Amplify so that you can create the necessary backend services needed to support the app.
Open a new terminal. From the root of the project, run:
When you initialize Amplify you'll be prompted for some information about the app:
When you initialize a new Amplify project, a few things happen:
- It creates a top level directory called
amplifythat stores your backend definition. During the tutorial you'll add cloud capabilities, such as GraphQL API and web hosting. As you add these features, the
amplifyfolder will grow with infrastructure-as-code templates that define your backend stack. Infrastructure-as-code is a best practice way to create a replicable backend stack.
- It creates a file called
- It modifies the
.gitignorefile, adding some generated files to the ignore list
aws-amplify package is the main library for working with Amplify Libraries in your projects. The
@aws-amplify/adapter-nextjs package includes additional Next.js-specific functions for using the Amplify libraries server-side:
1npm install aws-amplify @aws-amplify/adapter-nextjs
That's all it takes to install Amplify libraries with your Next.js application. Next, we'll create a new backend API and database tables. Then, we'll use the Amplify library's Next.js adapter to make API requests to your new backend.