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

@photonjs/cloudflare

v0.1.13

Published

Cloudflare Workers and Pages adapter for Photon, enabling deployment of universal web applications to Cloudflare's edge network.

Downloads

18,010

Readme

@photonjs/cloudflare

Cloudflare Workers and Pages adapter for Photon, enabling deployment of universal web applications to Cloudflare's edge network.

Overview

This adapter provides seamless integration between Photon and Cloudflare's runtime environments:

  • Cloudflare Workers: Deploy server functions to Cloudflare's edge network
  • Cloudflare Pages: Static site hosting with edge functions
  • Workerd Runtime: Local development with Cloudflare's runtime
  • WebSocket Support: Real-time applications with crossws integration
  • H3 Integration: Built-in support for H3 server framework

Installation

npm install @photonjs/cloudflare
# or
pnpm add @photonjs/cloudflare
# or
yarn add @photonjs/cloudflare

Usage

Basic Setup

Add the Cloudflare adapter to your Vite configuration:

// vite.config.ts
import { installPhoton } from '@photonjs/runtime/vite'
import { cloudflare } from '@photonjs/cloudflare/vite'

export default {
  plugins: [
    installPhoton({
      // optional
      server: './src/server.ts'
    }),
    cloudflare()
  ]
}

Wrangler Configuration

Configure Wrangler to use your Photon's virtual entry:

# wrangler.toml
name = "my-photon-app"
main = "virtual:photon:cloudflare:server-entry"
compatibility_date = "2025-08-28"

Server Integration

With Hono

// src/server.ts
import { Hono } from 'hono'
import { apply, serve } from '@photonjs/hono'

const app = new Hono()

app.get('/', (c) => c.text('Hello from Photon + Hono on Cloudflare!'))

apply(app)
export default serve(app)

With H3

// src/server.ts
import { createApp, defineEventHandler } from 'h3'
import { apply, serve } from '@photonjs/h3'

const app = createApp()

app.use('/', defineEventHandler(() => 'Hello from Photon + H3 on Cloudflare!'))

apply(app)
export default serve(app)

API Reference

Exports

  • ./vite - Vite plugin for Cloudflare integration
  • ./hono - Hono-specific Cloudflare utilities
  • ./h3 - H3-specific Cloudflare utilities
  • ./srvx - srvx-specific Cloudflare utilities
  • ./dev - Development server utilities
  • ./virtual - TypeScript declarations for virtual modules

Cloudflare-specific Functions

asFetch(app): ExportedHandlerFetchHandler

Converts a Hono app to a Cloudflare Workers fetch handler:

import { asFetch } from '@photonjs/cloudflare/hono'
import { Hono } from 'hono'

const app = new Hono()
export default { fetch: asFetch(app) }

Development

Local Development with Workerd

# Development with Cloudflare's workerd runtime
npm run dev:cloudflare
# or
pnpm dev:cloudflare

Building for Production

# Build for Cloudflare deployment
npm run build:cloudflare
# or
pnpm build:cloudflare

Environment Variables

Access Cloudflare environment variables and bindings:

// In your handlers
export default {
  async fetch(request, env, ctx) {
    // env contains your Cloudflare bindings
    const value = env.MY_KV_NAMESPACE.get('key')
    // ...
  }
}

WebSocket Support

Enable WebSocket support with crossws:

npm install crossws
// vite.config.ts
export default {
  plugins: [
    photon({
      server: './src/server.ts'
    }),
    cloudflare({
      // WebSocket support will be automatically detected
    })
  ]
}

Examples

See the example applications:

Deployment

Using Wrangler

# Deploy to Cloudflare Workers
wrangler deploy

# Deploy to Cloudflare Pages
wrangler pages deploy dist

Using GitHub Actions

# .github/workflows/deploy.yml
name: Deploy to Cloudflare
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
      - run: npm install
      - run: npm run build:cloudflare
      - uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}

License

MIT