Our great sponsors
-
static-website-boilerplate
Boilerplate for a serverless static website project - deployed to AWS using CloudFront and AWS.
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
light-server
A lightweight cli static http server and it can watch files, execute commands and trigger livereload
-
nextjs-bootstrap-boilerplate
Boilerplate for a Next.js Project using Bootstrap Styling. Configured for TypeScript and Terraform.
-
amplify-hosting
AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
In the following, I will discuss various aspects of hosting static website with S3 that we need to be aware of to enable all of the above. This article has a companion project on GitHub: static-website-boilerplate. Examples will refer to this project. The project is implemented using TypeScript and Terraform.
Consider helping out making this template better for others by raising an issue in GitHub if you encounter any problems or have questions or ideas.
The for the template (and in turn the boilerplate project), I decided to use the light-server library which among other features offers hot reload. In the template, you can simply run yarn watch to start the local development server.
Other frameworks that generate static files such as Gatsby also generate pages that can easily be uploaded to S3.
Next.js offers an option to generate a static HTML export for Next.js applications. Such an export can be uploaded as is to an S3 bucket configured as suggested here to serve a Next.js application through AWS. This is the approach I have used for the Next.js + Bootstrap and Next.js templates.
Next.js offers an option to generate a static HTML export for Next.js applications. Such an export can be uploaded as is to an S3 bucket configured as suggested here to serve a Next.js application through AWS. This is the approach I have used for the Next.js + Bootstrap and Next.js templates.
Hosting a simple static website is one of those things one would expect to be easier on AWS (it is by far from the only one). AWS seem to have recognised this and now offer the AWS Amplify Hosting service. I have not used this service myself but like other services branded under the Amplify umbrella it will come with the usual trade-off: a quicker setup for less flexibility.
Related posts
- [AskJS] Frameworks are often unnecessary (i got the suspicion by watching some YouTube videos that who advocates for frameworks and against vanilla JavaScript at the same time did not learn vanilla web technologies very well) what do you think? (Read the body)
- Topmost JAMstack Frontend Frameworks To Utilize In 2023
- From Gatsby to NextJS - journey of a blog
- What are use cases to NOT use create-react-app, but instead use alternatives or scaffold on your own?
- 7 Reasons Why React is King of JavaScript UI Frameworks