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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dbbs/next-serverless-deployment

v1.2.0

Published

## Introduction `@dbbs/next-serverless-deployment` is design to elevate the performance of NextJS applications by providing self-hosted solution with a robust caching solutions that are adapted to cookies, query parameters and device type.

Downloads

302

Readme

NextJS Serverless Deployment

Introduction

@dbbs/next-serverless-deployment is design to elevate the performance of NextJS applications by providing self-hosted solution with a robust caching solutions that are adapted to cookies, query parameters and device type.

Table of Contents

Features

  • Cache Segmentation: Dynamically segment application cache and user's experience based on cookies, query parameters and device type.
  • Customizable: Flexible configuration options to handle caching strategies for specific needs.
  • Deployment: Deploy your NextJS application just with a few commands.
  • Self-Hosted: Full control over infrastructure of your application.

Quick Start

Installation

npm install @dbbs/next-serverless-deployment
# or
yarn add @dbbs/next-serverless-deployment

Deployment

First of all need to bootstrap necessary components for AWS CDK:

@dbbs/next-serverless-deployment bootstrap

NOTE: this command should be called just once. It will call AWS CDK bootstrap to add ability to use cdk in your AWS account.

Then to deploy NextJS app run the following command:

@dbbs/next-serverless-deployment deploy --siteName my-awesome-app --stage development

This command is going to create all necessary AWS resources (if they do not exist yet), bundle NextJS application and upload all assets to AWS.

Cache config

Create next-serverless.config.js file in the root of your app. Config files allows you to specify cache behaviour of your application.

Default config:

/**
 * @type {import('next-serverless-deployment').CacheConfig}
 */
const config = {
  noCacheRoutes: [],
  cacheCookies: [],
  cacheQueries: [],
  enableDeviceSplit: false
}

module.exports = config
  • noCacheRoutes: specify list of routes which are going to be ignored to be cached.
  • cacheCookies: list of cookie names for cache fragmentation.
  • cacheQueries: list of query names for cache fragmentation.
  • enableDeviceSplit: flag to control cache fragmentation based on device type (desktop vs tablet vs mobile).

CLI

bootstrap

Creates all CDK resources for AWS account. This needs to be called just once for specific AWS region.

@dbbs/next-serverless-deployment bootstrap

deploy

Creates AWS resources for NextJS application if they were not created. Bundles NextJS application and uploads assets to AWS related services.

@dbbs/next-serverless-deployment deploy

Available parameters

| Parameter Name | Type | Default value | Description | |-------------------|---------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------| | siteName | string | none | Name which is going to be used for creating AWS resources | | stage | string | none | Adds prefix for AWS recource's names | | region | string | none | AWS region. If parameter is empty going to read process.env.AWS_REGION | | profile | string | none | AWS profile to use for credentials. If parameter is empty going to read credentials from:process.env.AWS_ACCESS_KEY_ID and process.env.AWS_SECRET_ACCESS_KEY | | nodejs | string | 20 | Supports nodejs v18 and v20 | | production | boolean | false | Identifies if you want to create production AWS resources. So they are going to have different delete policies to keep data in safe. |

Architecture

sequenceDiagram
    %% Nodes

    participant User
    participant CloudFront
    participant Request Origin Lambda@Edge
    participant Response Origin Lambda@Edge
    participant S3Bucket
    participant ElasticBeanstalk with Load Balancer

    %% Flows

    User ->> CloudFront: Send Request
    CloudFront ->> Request Origin Lambda@Edge: 
    Request Origin Lambda@Edge ->> S3Bucket: Sends Head request to check if file exists in S3
    alt File exists in S3
      Request Origin Lambda@Edge ->> S3Bucket: Forwarding request to S3 origin
      S3Bucket ->> Response Origin Lambda@Edge: lambda edge listener
      Response Origin Lambda@Edge ->> CloudFront: returns result from s3 origin
        alt File is expired in S3
          Response Origin Lambda@Edge ->> CloudFront: sets cache header to no-cache to avoid caching of stale data
        else
          Response Origin Lambda@Edge ->> CloudFront: forwards request from S3 origin
        end
    else File does not exit
      Request Origin Lambda@Edge ->> ElasticBeanstalk with Load Balancer: Sends request to render page when it does not exist in S3
      ElasticBeanstalk with Load Balancer ->> CloudFront: returns generated page
      ElasticBeanstalk with Load Balancer ->> S3Bucket: stores generated page
    end
    CloudFront ->> User: returns page result

Contributing

  • Code Contributions: When contributing code, ensure it adheres to the project's coding standards and write tests where applicable.
  • Documentation: If you are contributing to documentation, ensure your changes are clear, concise, and helpful for other users.
  • Bug Reports and Feature Requests: Use the GitHub Issues section to report bugs or suggest new features. Please provide as much detail as possible to help us understand the issue or feature.

License

The next-cache-handler is open-source software licensed under the MIT License.

Contact Information

We value your feedback and contributions to the next-cache-handler. If you have any questions or suggestions or need support, here are several ways to get in touch with us:

  • General Inquiries and Support: For any general questions about the platform or if you need assistance, please visit our website DBB Software and use the contact form provided.

  • GitHub Issues: For specific issues, feature requests, or bugs related to the platform, please use the GitHub Issues page. This is the fastest way to directly communicate with our development team and track the resolution of your issue.

  • Community Discussion and Contributions: Join our community discussions on GitHub Discussions for broader topics, ideas exchange, and collaborative discussions.

  • Social Media: Follow us on our social media channels for the latest news, updates, and insights:

  • Email Contact: For more formal or detailed inquiries, feel free to reach out to us via email at [email protected].

We're always here to help and are committed to ensuring you have the best experience with the next-cache-handler. Your input and participation drive the continuous improvement of our platform.