I'm looking into building a small project where I want to use React as my frontend and DynamoDB as my database, without any backend like an API Gateway or Lambda. My goal is to have my React app read and write data directly to DynamoDB. I've heard that the AWS SDK for JavaScript can enable this, but I'm unclear on how to set up authentication and permissions correctly. Can anyone share their experiences or suggestions on how to manage direct access to DynamoDB from a frontend app? What approaches should I consider for authentication and IAM policies? Are there any recommended AWS services or best practices that could simplify this no-backend configuration?
3 Answers
Be cautious with this approach. Remember, DynamoDB is primarily a key-value store, so if you're not careful with your data access patterns, you may run into issues with inefficiency or unexpected costs. Always implement permission controls when letting the frontend access your database directly.
Yes, you can absolutely have a React app communicate directly with DynamoDB! The way to do this is by using Cognito Identity Pools to get temporary IAM credentials, then interact with DynamoDB via the AWS SDK in your browser. This setup works for small, low-risk applications, but keep in mind that you're giving your frontend potential access to your data. For anything more than a toy project, I strongly recommend using AppSync instead, which lets you manage data access in a much safer way.
I wouldn't recommend doing that, honestly. Exposing your access keys directly within your app can be a recipe for disaster. If you really want to avoid backend services, at least consider using API Gateway to serve as a proxy to DynamoDB. Combine that with Cognito for authentication to securely manage user access.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically