Quick Start Guide
This guide walks you through the basics of installing and using @aws/nx-plugin to rapidly build projects on AWS.
Prerequisites
Section titled “Prerequisites”The following global dependencies are needed before proceeding:
Required
Section titled “Required”- Git
- Node >= 22 (We recommend using something like NVM to manage your node versions)
- verify by running
node --version
- verify by running
- UV >= 0.5.29
- install Python 3.14 by running:
uv python install 3.14 - verify with
uv python list --only-installed
- install Python 3.14 by running:
Recommended
Section titled “Recommended”- PNPM >= 11 (you can also use Yarn >= 4, Bun >= 1, or NPM >= 11 if you prefer)
- verify by running
pnpm --version,yarn --version,bun --versionornpm --version
- verify by running
- AWS Credentials configured to your target AWS account are required to deploy your application (as well as for some local development workflows).
- Docker or Finch >= 1.6.0 is required for some generators. For Docker, multi-platform builds must be set up; Finch supports multi-platform builds out of the box.
- Terraform >= 1.12 is required if you choose to use this for infrastructure as code instead of CDK
- verify by running
terraform --version
- verify by running
- If you are using VSCode, we recommend installing the Nx Console VSCode Plugin.
Step 1: Create a Workspace
Section titled “Step 1: Create a Workspace”Create an Nx workspace with the package manager of your choice, and open the directory it creates:
Create your workspace@aws/nx-workspace
pnpm create @aws/nx-workspace my-project yarn create @aws/nx-workspace my-project npm create @aws/nx-workspace -- my-project bun create @aws/nx-workspace my-projectBuild your command3
Required
cd my-projectYou are prompted to choose your infrastructure as code provider, either CDK or Terraform.
Step 2: Build Your Application
Section titled “Step 2: Build Your Application”We’ll build a full-stack application: a tRPC API, a React website, Cognito authentication, and CDK or Terraform infrastructure. Ask an AI assistant to scaffold it for you, or run the generators yourself — both routes reach the same workspace.
With AI
Section titled “With AI”-
Open the workspace in your AI coding assistant.
New workspaces come with the plugin’s MCP server already configured for Kiro, Claude Code, Cursor, Gemini CLI, GitHub Copilot and OpenAI Codex, so your assistant can look up the plugin’s generators and run them without any setup.
-
Ask for the application:
Prompt Create a tRPC API called demo-api, and a React website called demo-website. Add Cognito authentication to the website, connect the website to the API, and add an infrastructure project called infra. Then instantiate the generated infrastructure components so the website and API deploy, granting authenticated users access to the API.
Your assistant discovers the generators through the MCP server and runs them, in the order their dependencies need. Review the changes it makes, then carry on at Step 3.
With the CLI
Section titled “With the CLI”Run the generators that scaffold the application. Use the button below to copy them all, or run each one yourself as described beneath the diagram.
Depending on the type of project you’re building, you can choose any combination of generators to quickly bootstrap your project. Check out the Generators in the navigation bar to the left to see the full list of options, or try the graph builder to construct your workspace visually.
Add a tRPC API
Section titled “Add a tRPC API”Run this generator@aws/nx-plugin:ts#api
pnpm nx g @aws/nx-plugin:ts#api --no-interactive yarn nx g @aws/nx-plugin:ts#api --no-interactive npx nx g @aws/nx-plugin:ts#api --no-interactive bunx nx g @aws/nx-plugin:ts#api --no-interactive- Install the Nx Console VSCode Plugin if you haven't already
- Open the Nx Console in VSCode
- Click
Generate (UI)in the "Common Nx Commands" section - Search for
@aws/nx-plugin - ts#api - Fill in the required parameters
- Click
Generate
Options for this step2
Required
This will create the API inside the packages/demo-api folder.
Add a React Website
Section titled “Add a React Website”Run this generator@aws/nx-plugin:ts#website
pnpm nx g @aws/nx-plugin:ts#website --no-interactive yarn nx g @aws/nx-plugin:ts#website --no-interactive npx nx g @aws/nx-plugin:ts#website --no-interactive bunx nx g @aws/nx-plugin:ts#website --no-interactive- Install the Nx Console VSCode Plugin if you haven't already
- Open the Nx Console in VSCode
- Click
Generate (UI)in the "Common Nx Commands" section - Search for
@aws/nx-plugin - ts#website - Fill in the required parameters
- Click
Generate
Options for this step1
Required
This scaffolds a new React website in packages/demo-website.
Add Cognito Authentication
Section titled “Add Cognito Authentication”Run this generator@aws/nx-plugin:ts#website#auth
pnpm nx g @aws/nx-plugin:ts#website#auth --no-interactive yarn nx g @aws/nx-plugin:ts#website#auth --no-interactive npx nx g @aws/nx-plugin:ts#website#auth --no-interactive bunx nx g @aws/nx-plugin:ts#website#auth --no-interactive- Install the Nx Console VSCode Plugin if you haven't already
- Open the Nx Console in VSCode
- Click
Generate (UI)in the "Common Nx Commands" section - Search for
@aws/nx-plugin - ts#website#auth - Fill in the required parameters
- Click
Generate
Options for this step1
Required
This sets up the necessary infrastructure and React code to add Cognito Authentication to your website.
Connect Frontend to Backend
Section titled “Connect Frontend to Backend”Run this generator@aws/nx-plugin:connection
pnpm nx g @aws/nx-plugin:connection --no-interactive yarn nx g @aws/nx-plugin:connection --no-interactive npx nx g @aws/nx-plugin:connection --no-interactive bunx nx g @aws/nx-plugin:connection --no-interactive- Install the Nx Console VSCode Plugin if you haven't already
- Open the Nx Console in VSCode
- Click
Generate (UI)in the "Common Nx Commands" section - Search for
@aws/nx-plugin - connection - Fill in the required parameters
- Click
Generate
Options for this step2
Required
Required
This configures the necessary providers to ensure your website can call your tRPC API.
Add Infrastructure
Section titled “Add Infrastructure”Add the infrastructure project based on your chosen IAC provider.
Run this generator@aws/nx-plugin:ts#infra
pnpm nx g @aws/nx-plugin:ts#infra --no-interactive yarn nx g @aws/nx-plugin:ts#infra --no-interactive npx nx g @aws/nx-plugin:ts#infra --no-interactive bunx nx g @aws/nx-plugin:ts#infra --no-interactive- Install the Nx Console VSCode Plugin if you haven't already
- Open the Nx Console in VSCode
- Click
Generate (UI)in the "Common Nx Commands" section - Search for
@aws/nx-plugin - ts#infra - Fill in the required parameters
- Click
Generate
Options for this step1
Required
This configures a CDK App which you can use to deploy your infrastructure on AWS.
Run this generator@aws/nx-plugin:terraform#project
pnpm nx g @aws/nx-plugin:terraform#project --no-interactive yarn nx g @aws/nx-plugin:terraform#project --no-interactive npx nx g @aws/nx-plugin:terraform#project --no-interactive bunx nx g @aws/nx-plugin:terraform#project --no-interactive- Install the Nx Console VSCode Plugin if you haven't already
- Open the Nx Console in VSCode
- Click
Generate (UI)in the "Common Nx Commands" section - Search for
@aws/nx-plugin - terraform#project - Fill in the required parameters
- Click
Generate
Options for this step1
Required
This configures a Terraform project which you can use to deploy your infrastructure on AWS.
Step 3: Run your Website and API Locally
Section titled “Step 3: Run your Website and API Locally”Use the following command to start local dev servers for your website and its connected APIs:
pnpm devyarn devnpm run devbun devYour website will be available at http://localhost:4200.
Changes to both your website and API will be reflected in real-time as both the local website and API servers will hot-reload.
Calling your API from your website
Connecting the website to the API added a useDemoApi hook, which returns a tRPC options proxy: every procedure on your API offers queryOptions and mutationOptions to hand to TanStack Query.
Update packages/demo-website/src/routes/index.tsx to call the API’s echo procedure, showing a spinner while the request is in flight:
import { useQuery } from '@tanstack/react-query';import { createFileRoute } from '@tanstack/react-router';import { Spinner } from '../components/spinner';import { useDemoApi } from '../hooks/useDemoApi';
export const Route = createFileRoute('/')({ component: RouteComponent,});
function RouteComponent() { const trpc = useDemoApi(); const echo = useQuery( trpc.echo.queryOptions({ message: 'Hello from the API!' }), );
return ( <div className="text-center"> <header> <h1>Welcome</h1> <p>Welcome to your new React website!</p> </header> {echo.isLoading ? ( <Spinner /> ) : echo.error ? ( <p>Error: {echo.error.message}</p> ) : ( <p>{echo.data?.message}</p> )} </div> );}Save the file and the page reloads with the message your API echoed back. The call is type-safe end to end — rename message in packages/demo-api/src/schema/echo.ts and your website stops compiling until you follow the change through.
See the React to tRPC connection guide for mutations, subscriptions, error handling and optimistic updates.
Step 4: Define Cloud Resources and Deploy to AWS
Section titled “Step 4: Define Cloud Resources and Deploy to AWS”Open packages/infra/src/stacks/application-stack.ts and add the following code:
import { DemoApi, DemoWebsite, UserIdentity,} from '@my-project/common-constructs';import { Stack, StackProps } from 'aws-cdk-lib';import { Construct } from 'constructs';
export class ApplicationStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props);
const identity = new UserIdentity(this, 'identity'); const api = new DemoApi(this, 'api', { integrations: DemoApi.defaultIntegrations(this).build(), }); api.grantInvokeAccess(identity.identityPool.authenticatedRole);
new DemoWebsite(this, 'website'); }}This is all the CDK we need to write to deploy our full stack application.
Open packages/infra/src/main.tf and add the following code:
# Deploy user identitymodule "user_identity" { source = "../../common/terraform/src/core/user-identity"}
# Shared asset bucket — stages Lambda deployment zips for every lambda / API modulemodule "asset_bucket" { source = "../../common/terraform/src/core/asset-bucket"}
# Deploy APImodule "demo_api" { source = "../../common/terraform/src/app/apis/demo-api"
asset_bucket_name = module.asset_bucket.bucket_name}
# Grant authenticated users access to invoke the APIresource "aws_iam_policy" "api_invoke_policy" { name = "DemoApiInvokePolicy" description = "Policy to allow authenticated users to invoke the API"
policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Action = "execute-api:Invoke" Resource = "${module.demo_api.api_execution_arn}/*/*" } ] })}
resource "aws_iam_role_policy_attachment" "authenticated_api_access" { role = module.user_identity.authenticated_role_name policy_arn = aws_iam_policy.api_invoke_policy.arn}
# Deploy websiteprovider "aws" { alias = "us_east_1" region = "us-east-1"}
module "demo_website" { source = "../../common/terraform/src/app/static-websites/demo-website"
providers = { aws.us_east_1 = aws.us_east_1 }
depends_on = [module.user_identity, module.demo_api]}
# Print the website URL and user pool id when the deployment finishesoutput "website_url" { value = module.demo_website.website_url}
output "user_pool_id" { value = module.user_identity.user_pool_id}This is all the Terraform we need to write to deploy our full stack application.
Build and Deploy the Infrastructure
Section titled “Build and Deploy the Infrastructure”Next, run the following command to build your project:
pnpm buildyarn buildnpm run buildbun buildBootstrap your infrastructure:
pnpm nx bootstrap infrayarn nx bootstrap infranpx nx bootstrap infrabunx nx bootstrap infrapnpm nx bootstrap infrayarn nx bootstrap infranpx nx bootstrap infrabunx nx bootstrap infraDeploy your project:
pnpm nx deploy-sandbox infrayarn nx deploy-sandbox infranpx nx deploy-sandbox infrabunx nx deploy-sandbox infrapnpm nx apply infrayarn nx apply infranpx nx apply infrabunx nx apply infraStep 5: Test the Website with Deployed Cloud Resources
Section titled “Step 5: Test the Website with Deployed Cloud Resources”-
Fetch the
runtime-config.jsonfile:Terminal window pnpm nx load-runtime-config demo-websiteTerminal window yarn nx load-runtime-config demo-websiteTerminal window npx nx load-runtime-config demo-websiteTerminal window bunx nx load-runtime-config demo-website -
Start the local website server
Terminal window pnpm nx serve demo-websiteTerminal window yarn nx serve demo-websiteTerminal window npx nx serve demo-websiteTerminal window bunx nx serve demo-website
Your website will be available at http://localhost:4200, and will point to the resources you deployed for the API and authentication.
To sign in, you will need to create a user in the Cognito user pool.
Creating a user with the AWS CLI
The following command creates a user in a user pool. You can find the user pool id in your deployment outputs, or in the Amazon Cognito console. Substitute values for username, email, first and last name, and the temporary password.
aws cognito-idp admin-create-user \ --user-pool-id <user pool id> \ --username <username> \ --user-attributes Name=email,Value=<email> Name=email_verified,Value=true Name=given_name,Value=<first name> Name=family_name,Value=<last name> \ --temporary-password '<temporary password>' \ --message-action SUPPRESSThe first time you sign in as this user you are prompted to choose a new password, then to set up multi-factor authentication with either a code sent by SMS or a time-based one time password from an authenticator app.
Your website is also served from CloudFront. Open its distribution domain name (which is printed to your terminal after deployment) to use the version running entirely on AWS.
Congratulations! 🎉 You have successfully built and deployed a full-stack application using @aws/nx-plugin!
Step 6: Clean Up
Section titled “Step 6: Clean Up”When you have finished, delete the resources you deployed to avoid ongoing costs:
pnpm nx destroy-sandbox infrayarn nx destroy-sandbox infranpx nx destroy-sandbox infrabunx nx destroy-sandbox infrapnpm nx destroy infrayarn nx destroy infranpx nx destroy infrabunx nx destroy infraTo remove bootstrap resources, follow below:
Delete the bootstrap stack in every region you bootstrapped, including us-east-1. This removes the bootstrap roles and the container image repository:
aws cloudformation delete-stack --stack-name CDKToolkit --region <region>pnpm nx bootstrap-destroy infrayarn nx bootstrap-destroy infranpx nx bootstrap-destroy infrabunx nx bootstrap-destroy infraNext Steps
Section titled “Next Steps”- Dungeon Adventure Tutorial — build a full-stack AI dungeon adventure game, for a more in-depth walkthrough than this guide.
- Workspaces — how your workspace is laid out, and the configuration the generators share.
- Add to an Existing Project — adopt the plugin in your existing codebase.