0.0.17 • Published 1 year ago

next-s3 v0.0.17

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

About The Project

Product Name Screen Shot

A tiny CLI tool to host any of your static next.js sites on AWS S3 and Cloudfront.

There are many great ways to host a Next.js app, especially vercel but there are times, when they are simply just overkill - and can even result in slower load times than a regular static site.

With that said, there are some pros and cons against hosting on S3;

Pros:

  • There is no need for a server, your files will be hosted statically, which is simply faster.
  • You can utilize Cloudfront's built-in GZipping, which will reduce your load times even more

Cons:

  • Only static sites can be hosted on S3, with absolutely no SSR or ISG.
  • You can not use any of Next's built-in API or middle-ware logic.
  • A 3rd party image optimizer has to be used - or none at all.

I know there are other web frameworks, created for such type of hosting but let's be honest; working on a next.js project can't be compared DX-wise to any other production framework.

Getting Started

Installation

Using NPM

npm install --save-dev next-s3

or using yarn

yarn add -D next-s3

Note: It is recommended to install the page as a dev dependency.

Usage

Run the following command from inside your Next.js project:

next-s3 deploy --bucket <bucket-name> --distribution <cloudfront distribution id>

Note: I assume the package has been installed globally.

Parameters

All the parameters available to use:

OptionDotenv keyRequiredDescriptionDefault
-p, --profileNEXT_S3_PROFILENoName of the local AWS profile which will be used-
--publicKeyNEXT_S3_PUBLIC_KEYNoPublic access key which will be used during upload-
--secretKeyNEXT_S3_PRIVATE_KEYNoSecret key generated for the public key-
-b, --bucketNEXT_S3_BUCKETYesThe name of the S3 bucket to be used.-
-d, --distributionNEXT_S3_DISTRIBUTIONNoCloudformation ID to be invaidated after deployment.-
-p, --basepathNEXT_S3_BASEPATHNoBase path the site will be available under.'/'
--manager-NoPackage manager to be used to run commands.'yarn'
-v, --verbose-NoEnable verbose loggingfalse

Examples

Upload a site to an S3 bucket and Cloudfront:

next-s3 deploy --bucket <bucket-name> --distribution <cloudfront distribution id>

Upload a site to an S3 bucket and Cloudfront using a different profile:

next-s3 deploy --bucket <bucket-name> --distribution <cloudfront distribution id> --profile <profile>

Upload a site to an S3 bucket and Cloudfront using and host under the /production basepath:

next-s3 deploy --bucket <bucket-name> --distribution <cloudfront distribution id> --basepath "/production"

Roadmap

  • Create initial version
  • Add `dotenv^ support
  • Add custom config options
  • Create additional commands
    • Project scaffolding
  • Create github action

See the open issues for a full list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Balazs Szalay - @szalayme - balazs@szalay.me

0.0.16

1 year ago

0.0.17

1 year ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago