@ogpipe/next 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # @ogpipe/next
2
+
3
+ **Pixel-perfect OG images for Next.js — full CSS, any font, any hosting platform.**
4
+
5
+ Drop-in replacement for `@vercel/og` that uses real Chromium rendering. No Satori CSS limitations, no font-loading boilerplate, works on any deployment target.
6
+
7
+ ## Why?
8
+
9
+ `@vercel/og` uses Satori (an SVG renderer), not a real browser. This means:
10
+ - ❌ No CSS Grid
11
+ - ❌ No `display: block` or `display: inline`
12
+ - ❌ No `calc()`, no `z-index`, no 3D transforms
13
+ - ❌ No WOFF2 fonts
14
+ - ❌ Flexbox-only layouts with rendering quirks
15
+ - ❌ Only works well on Vercel
16
+
17
+ **@ogpipe/next** uses real Chromium (headless, on Lambda). This means:
18
+ - ✅ Any CSS that works in Chrome works here
19
+ - ✅ Any font format (TTF, OTF, WOFF, WOFF2, Google Fonts)
20
+ - ✅ Tailwind CSS, CSS Grid, complex layouts — all supported
21
+ - ✅ Deploy anywhere (Vercel, AWS, Netlify, Cloudflare, self-hosted)
22
+ - ✅ Pixel-perfect rendering — what you see in DevTools is what you get
23
+
24
+ ## Quick Start
25
+
26
+ ```bash
27
+ npm install @ogpipe/next
28
+ ```
29
+
30
+ ### 1. Create a config
31
+
32
+ ```ts
33
+ // ogpipe.config.ts
34
+ import { defineConfig } from '@ogpipe/next'
35
+
36
+ export default defineConfig({
37
+ templates: {
38
+ blog: { file: './og-templates/blog.html' },
39
+ default: {
40
+ html: `<div style="display:flex; width:1200px; height:630px; background:#1a1a2e; align-items:center; justify-content:center; padding:60px;">
41
+ <h1 style="color:white; font-size:56px;">{{title}}</h1>
42
+ </div>`,
43
+ },
44
+ },
45
+ routes: {
46
+ '/blog/[slug]': {
47
+ template: 'blog',
48
+ vars: (meta) => ({ title: meta.title || '', date: meta.params?.slug || '' }),
49
+ },
50
+ '*': { template: 'default' },
51
+ },
52
+ })
53
+ ```
54
+
55
+ ### 2. Add to your build script
56
+
57
+ ```json
58
+ {
59
+ "scripts": {
60
+ "build": "next build && ogpipe generate"
61
+ }
62
+ }
63
+ ```
64
+
65
+ ### 3. Set your API key
66
+
67
+ ```bash
68
+ export OGPIPE_API_KEY=og_live_your_key_here
69
+ ```
70
+
71
+ Get a free key (50 renders/month) at [ogpipe.dev/signup.html](https://ogpipe.dev/signup.html).
72
+
73
+ ### 4. Build — OG images generated automatically
74
+
75
+ ```bash
76
+ npm run build
77
+ # → ✅ Generated 12 OG images in 4200ms
78
+ # → 📁 Output: public/og/
79
+ ```
80
+
81
+ ## Local Preview (Dev Mode)
82
+
83
+ See your OG images in real-time with hot-reload:
84
+
85
+ ```bash
86
+ npx ogpipe dev
87
+ # → ⚡ OGPipe Dev Preview
88
+ # → http://localhost:3010
89
+ ```
90
+
91
+ Preview shows your images inside Twitter, LinkedIn, Slack, and Discord frames. Edit a template → preview updates instantly.
92
+
93
+ ## Dynamic Routes (On-Demand)
94
+
95
+ For pages created after build (blogs, products, UGC), use the on-demand handler:
96
+
97
+ ```ts
98
+ // app/blog/[slug]/opengraph-image.ts
99
+ import { OGImageHandler } from '@ogpipe/next'
100
+
101
+ export default OGImageHandler({
102
+ html: `<div style="...">{{title}}</div>`,
103
+ vars: (params) => ({
104
+ title: params.slug.replace(/-/g, ' ').replace(/\b\w/g, c => c.toUpperCase()),
105
+ }),
106
+ revalidate: 86400, // cache 24h
107
+ fallback: '/og-fallback.png',
108
+ })
109
+ ```
110
+
111
+ First request renders via API (~1-2s). All subsequent requests serve from CDN cache.
112
+
113
+ ## Templates
114
+
115
+ Templates are HTML files with `{{variable}}` placeholders. Use any CSS:
116
+
117
+ ```html
118
+ <!-- og-templates/blog.html -->
119
+ <!DOCTYPE html>
120
+ <html>
121
+ <head>
122
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@700&display=swap" rel="stylesheet">
123
+ <script src="https://cdn.tailwindcss.com"></script>
124
+ </head>
125
+ <body class="w-[1200px] h-[630px] flex flex-col justify-center p-20 bg-gradient-to-br from-blue-600 to-purple-700">
126
+ <h1 class="text-5xl font-bold text-white">{{title}}</h1>
127
+ <p class="text-xl text-blue-100 mt-4">{{description}}</p>
128
+ <p class="text-lg text-blue-200 mt-auto">{{author}} · {{date}}</p>
129
+ </body>
130
+ </html>
131
+ ```
132
+
133
+ ## API Client (Framework-Agnostic)
134
+
135
+ Use the raw API client from any Node.js context:
136
+
137
+ ```ts
138
+ import { OGPipeClient } from '@ogpipe/next/client'
139
+
140
+ const client = new OGPipeClient({ apiKey: process.env.OGPIPE_API_KEY })
141
+ const result = await client.render({
142
+ html: '<div style="...">Hello World</div>',
143
+ width: 1200,
144
+ height: 630,
145
+ })
146
+
147
+ if (result.success) {
148
+ console.log(result.data.url) // → CDN URL of rendered image
149
+ }
150
+ ```
151
+
152
+ ## Pricing
153
+
154
+ | Plan | Renders/mo | Price |
155
+ |------|-----------|-------|
156
+ | Free | 50 | $0 |
157
+ | Pro | 5,000 | $19/mo |
158
+ | Scale | 25,000 | $49/mo |
159
+
160
+ Get your key at [ogpipe.dev](https://ogpipe.dev).
161
+
162
+ ## License
163
+
164
+ MIT
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node