npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

serverless-website-domain

v3.0.2

Published

A serverless plugin that creates Route 53 records that point to your Cloudfront hosted static website.

Readme

serverless-website-domain

A Serverless plugin specifically designed to set up domains for your static website (not API Gateway). It creates Route 53 entries that point to your Cloudfront Distribution.

Features:

  • Maps both HTTP & HTTPS non-www variants of your domain to https://www.yourdomain.com
  • Works alongside other popular plugins:
    • serverless-certificate-creator
    • serverless-s3-sync
    • serverless-cloudfront-invalidate
  • Simple examples in /examples folder

Prerequisites

This plugin requires that you use at serverless v3 as it relies on variableResolutionMode 20210326

Before running you must manually create a Hosted Zone in Route 53. with domain name yourdomain.com

How to use?

Add the plugin to your serverless.yml

plugins:
  -serverless-website-domain

Add plugin configuration to serverless.yml

custom:
  domainComponents: #Key not needed, just used as example.
    withWWW: www.${self:custom.domainComponents.withoutWWW}
    withoutWWW: yourdomain.com
  websiteDomain:
    disabled: false # defaults to false. enable to prevent DNS changes if needed (e.g. per env)
    cloudfrontOutputKey: 'yourCloudfrontDomainName'
    domain: ${self:custom.domainComponents.withWWW} #must be hostedZoneDomain or subdomain of it
    edgeLambda:
      basicAuthCredentials: ${env:BASIC_AUTH_CREDENTIALS} #e.g user/password
      redirect:
        from: ${self:custom.domainComponents.withoutWWW}
        to: https://${self:custom.domainComponents.withWWW}
variablesResolutionMode: 20210326
resources:
  Outputs:
    yourCloudfrontDomainName:
      Value:
        'Fn::GetAtt': [ CloudFrontDistribution, DomainName ]
  Resources
    CloudFrontDistribution:
      Type: AWS::CloudFront::Distribution
      Properties:
        DistributionConfig:
          Aliases:
          - ${self:custom.domainComponents.withWWW}
          - ${self:custom.domainComponents.withoutWWW}
          DefaultCacheBehavior:
            LambdaFunctionAssociations:
              - EventType: viewer-request
                LambdaFunctionARN: ${websiteDomain(edgeLambdaArn)}
          ViewerCertificate:
            #manually specify ARN:
            AcmCertificateArn: ${certificate(${self:custom.customCertificate.certificateName}):CertificateArn}

How to run

To create the domain

serverless create-edge-lambda #If you are using custom.websiteDomain.edgeLambda
serverless deploy #Called in after:deploy hook

There are also other manual commands you can run:

serverless remove-domain
serverless create-domain
serverless remove-edge-lambda

create-domain will also be called automatically by serverless deploy during the after:deploy hook. The recommended approach is to not use 'createDomain' and instead let it run automatically during deploy as it is dependent on the Cloudfront distribution first being deployed.

If you are using alongside serverless-certificate-creator you should call serverless create-cert before serverless create-redirect. You must also ensure that you include both www & non-www variants in subjectAlternativeNames. E.G:

customCertificate:
  certificateName: ${self:custom.domainComponents.withWWW}
  hostedZoneNames: ${env:AWS_ROUTE53_HOSTED_ZONE_DOMAIN_NAME}.
  subjectAlternativeNames:
    - '${self:custom.domainComponents.withoutWWW}'

Examples

It's highly recommended to look at the files in the examples directory to start with. It shows how to use this plugin alongside serverless-certificate-creator, serverless-s3-sync & serverless-cloudfront-invalidate for a full solution including environment specific domains (e.g env.yourdomain.com).

Parameters

| Name | Required | Data Type | Default | Description | |---------------------|----------|-----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | cloudfrontOutputKey | Y | String | | Should match key in resource.outputs which contains Cloudfront domain name (e.g 'Fn::GetAtt': [ CloudFrontDistribution, DomainName ]). | | domain | Y | String | | The domain you want to create. (e.g sub.yourdomain.com or yourdomain.com). Must exist under hosted zone of hostedZoneId. | | edgeLambda | N | Object | NULL | Parent property | | basicAuthCredentials | N | String | NULL | Specify to guard website with basic auth. Separate username & password with '/' or use 'false' to disable. | | redirect | N | Object | NULL | Parent property. | | redirect.from | Y | Object | NULL | Required if .redirect set. 'It will be matched against lambda request.host[0]. It will also create a route 53 A & AAAA record for it. If you want to redirect from yourdomain.com to www.yourdomain.com just enter 'yourdomain.com' here. | | redirect.to | Y | Object | NULL | Required if .redirect set. It is the full destination URL including protocol. (E.G https://www.yourdomain.com) . |