Local Development
How to work with your deployed AI SaaS platform locally for development and testing
Local Development
This guide explains how to set up and run the frontend of your AI SaaS platform locally for development and testing. The local frontend will connect to your deployed backend services on AWS, allowing you to develop and test UI changes quickly without affecting the live application.
Prerequisites
Before starting local development, ensure you have:
- Successfully deployed your AI SaaS platform to AWS
- Completed all integration steps (Stripe, Google OAuth, etc.)
- Node.js and npm installed on your local machine
Environment Variables Required: If you're on a different machine than where you deployed, you'll need to set up the project environment variables first. The commands in this guide require these environment variables:
PROJECT_ROOT
- Path to the project root directoryCDK_DIR
- Path to the CDK directoryAPP_NAME
- Application name from environment variablesSTAGE
- Deployment stage (dev/prod)AWS_DEFAULT_REGION
- AWS region for deployment
If you don't have these set up, please refer back to the Deployment Configuration section to set up these variables, or run this quick verification:
All variables should show their values. If any are empty, you need to set them up before proceeding.
Setting Up Local Development
Create Local Environment File
Create a .env.local
file in the frontend directory with the following template:
The regions are pre-configured to match your deployment region (eu-west-2). Set NEXT_PUBLIC_APP_NAME to match your APP_NAME from the deployment configuration. The other empty values need to be filled with your actual deployment values.
Get Your Deployment Values
You need to fill in the empty values in your .env.local
file. You can get these values in two ways:
Option A: Visual Guide
Watch the comprehensive video guide available on the main documentation page that shows you how to find these values in the AWS Console.
Option B: Using CloudFormation Commands
Run these commands to automatically retrieve the values from your deployment:
Copy the output values and paste them into your .env.local
file, replacing the empty strings.
For NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
, use the same Stripe publishable key you configured during the Stripe setup process.
Install Dependencies
Install the required Node.js dependencies:
This will install all the packages needed to run the frontend locally, including Next.js, React, and AWS SDK components.
Start the Development Server
Run the Next.js development server:
The development server will start and be available at http://localhost:3000.
The local frontend will connect to your deployed backend services on AWS, so all features should work exactly as they do in the deployed version.
Verifying Local Development Setup
Access Your Local Application
Open your web browser and navigate to http://localhost:3000. You should see your AI SaaS platform loading locally.
Test Authentication
Try signing in with an existing account or creating a new account to verify that authentication is working correctly with your deployed Cognito setup.
Test Core Features
Verify that key features are working:
- User dashboard loads correctly
- Credit balance is displayed
- Subscription information is accessible
- AI services are available (if you have credits)
All data interactions happen with your deployed AWS services, so any changes you make (like using credits or updating profile information) will be reflected in both local and deployed versions.
Understanding Local Development
When running the frontend locally:
- Frontend: Runs on your local machine at http://localhost:3000
- Backend services: Still running in AWS (Lambda functions, API Gateway, etc.)
- Authentication: Uses your deployed AWS Cognito configuration
- Data storage: Uses your deployed AWS S3 buckets and DynamoDB tables
- Payment processing: Uses your configured Stripe account
This setup allows you to:
- Make changes to the frontend code and see results immediately
- Debug frontend issues more easily
- Test new UI features before deploying
- Customize the interface without affecting the live application
Making and Testing Changes
Edit Frontend Code
Make changes to any file in the frontend
directory. The development server will automatically reload the page when you save changes.
Test Your Changes
Your changes will be immediately visible at http://localhost:3000. Test thoroughly to ensure everything works as expected.
Deploy Changes (When Ready)
When you're satisfied with your changes, deploy them to your live application:
AWS Amplify will automatically build and deploy your frontend changes when you push to your repository.
Best Practices
- Test thoroughly locally before pushing changes to your repository
- Use version control to track all changes
- Keep environment files secure - never commit
.env.local
to version control - Monitor AWS costs during development as requests still go through AWS services
- Create feature branches for major changes before merging to main
Next Steps
Now that you have local development set up, you can:
- Customize the user interface to match your brand
- Add new features to the platform
- Modify existing components and pages
- Test integrations with third-party services