New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cinematix/next-cloudflare

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cinematix/next-cloudflare

Utilities for hosting static Next.js site on Cloudflare Workers Sites

  • 1.1.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

next-cloudflare

Utilities for hosting static Next.js site on Cloudflare Workers Sites.

NOTE: This library works with static Next.js sites. It does not support server-side rendering or API routes. See zeit/next.js#11326

Installation

npm install --save @cinematix/next-cloudflare

Quick Start

From a new or existing Workers Site create a handler like this:

import { getEventHandler } from '@cinematix/next-cloudflare';
import routesManifest from './.next/routes-manifest.json';

const handleEvent = getEventHandler(routesManifest);

addEventListener('fetch', handleEvent);

Before building the worker, be sure to run npx next build && npx next export to generate the routes manifest. Alternatively, add a script like this to your package.json:

{
  "scripts": {
    "build": "next build && next export && wrangler publish"
  }
}

API

getEventHandler(routesManifest: object): function(event: Event) : void

Returns an event handler for the fetch event in a Cloudflare Worker. Uses event.respondWith() to handle the event.

getAsset(event: Event, routesManifest?: object): Promise<Response>

Returns the KV Asset based on the route. Resolves any dynamic routes and not found routes from the routesManifest.

getNotFoundAsset(event: Event): Promise<Response>

Returns the KV Asset for the 404.html page.

FAQs

Package last updated on 16 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc