{"_id":"@api-buddy/sendgrid","_rev":"6-da35c9b5610c0fb51d43be2ef39a442c","name":"@api-buddy/sendgrid","dist-tags":{"latest":"3.0.0"},"versions":{"0.1.0":{"name":"@api-buddy/sendgrid","version":"0.1.0","keywords":["sendgrid","email","transactional","marketing","nextjs","api"],"author":{"name":"API Buddy Team"},"license":"MIT","_id":"@api-buddy/sendgrid@0.1.0","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy/tree/main/packages/email/sendgrid#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-sendgrid":"cli.cjs"},"dist":{"shasum":"070f7d84c6a6f0d4ed2527d8d06174d10a579175","tarball":"https://registry.npmjs.org/@api-buddy/sendgrid/-/sendgrid-0.1.0.tgz","fileCount":17,"integrity":"sha512-ADortKEFuQZ4BkzzHZCZEKzoTP1hSyWc6DhymGrCocwLoiQKhE1AtnyJt/ALDby/Dw6GBfCesklPmbYPQXtXcg==","signatures":[{"sig":"MEUCIFEzfT333EMqyTkIFOpxge3IG3Kz+7+nnrlUIasPoF4oAiEAoxJ4x/dyq3X8xK7QegPJhE5fGpDqQrj9WFXC/In3OKc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":87785},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"8b500e7d4996fe7d7b7147bd939e9a4468b3099e","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch --external @sendgrid/mail","build":"tsup src/index.ts --format esm,cjs --dts --external @sendgrid/mail --tsconfig tsconfig.build.json","clean":"rm -rf dist","prepublishOnly":"npm run build"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"repository":{"url":"git+https://github.com/api-buddy/api-buddy.git#main","type":"git"},"_npmVersion":"9.8.1","description":"API Buddy integration for SendGrid - Email delivery service for transactional and marketing emails","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/core":"^0.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.8.3","@types/node":"^20.11.28","@types/react":"^18.3.23","@types/react-dom":"^19.1.6"},"peerDependencies":{"next":">=13.0.0","react":">=18.0.0","@sendgrid/mail":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sendgrid_0.1.0_1749436342097_0.5417971447842982","host":"s3://npm-registry-packages-npm-production"}},"0.4.107":{"name":"@api-buddy/sendgrid","version":"0.4.107","keywords":["sendgrid","email","transactional","marketing","nextjs","api"],"author":{"name":"API Buddy Team"},"license":"MIT","_id":"@api-buddy/sendgrid@0.4.107","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy/tree/main/packages/email/sendgrid#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-sendgrid":"cli.cjs"},"dist":{"shasum":"981ed121ca2339001f08ccd37901082654958042","tarball":"https://registry.npmjs.org/@api-buddy/sendgrid/-/sendgrid-0.4.107.tgz","fileCount":35,"integrity":"sha512-bQoyCOUqrv7UaxytFRxO0zwT09V/PPrPZKEAozuEqcappR/35Xb81at4Ike85X3r1ZRXpvb5E1NEBMSqafA8LQ==","signatures":[{"sig":"MEUCIQCL34M4piTHKTptGMRK4hKH5YTHnOU0cMexa3LQ5k0TQgIgWgQ9ShDaD1x/KqJroYQVoZnw2Fy6AGxQLz9FRsjCFf0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122711},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ce0089122abaa9fcfc04053fc31cd6afd64b01f7","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch --external @sendgrid/mail","build":"tsup src/index.ts --format esm,cjs --dts --external @sendgrid/mail --tsconfig tsconfig.build.json","clean":"rm -rf dist","prepublishOnly":"npm run build"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"repository":{"url":"git+https://github.com/api-buddy/api-buddy.git#main","type":"git"},"_npmVersion":"9.8.1","description":"API Buddy integration for SendGrid - Email delivery service for transactional and marketing emails","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/core":"^0.4.107"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.8.3","@types/node":"^20.11.28","@types/react":"^18.3.23","@types/react-dom":"^19.1.6"},"peerDependencies":{"next":">=13.0.0","react":">=18.0.0","@sendgrid/mail":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sendgrid_0.4.107_1749659034385_0.017221972924676754","host":"s3://npm-registry-packages-npm-production"}},"0.4.108":{"name":"@api-buddy/sendgrid","version":"0.4.108","keywords":["sendgrid","email","transactional","marketing","nextjs","api"],"author":{"name":"API Buddy Team"},"license":"MIT","_id":"@api-buddy/sendgrid@0.4.108","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy/tree/main/packages/email/sendgrid#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-sendgrid":"cli.cjs"},"dist":{"shasum":"6479604464d5ec02f65796cf72935ba27301fe3c","tarball":"https://registry.npmjs.org/@api-buddy/sendgrid/-/sendgrid-0.4.108.tgz","fileCount":35,"integrity":"sha512-JVkCHy6DS99Cvcg/rqQnkO9Ddov5LBe66qSiE7y2EvEJXyzIZC9zm78kQXaAi3bYtqJq9pHggbekLwFhb2ugsQ==","signatures":[{"sig":"MEUCIHKPip4KVKcHRnDmifvk2hZrS1yS+lsO9t14vZUcAvwUAiEA8cz4EK5QBf8TtoiWIBfcxwEWA6nZcqXWyCR0duC74Do=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122711},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"ce0089122abaa9fcfc04053fc31cd6afd64b01f7","scripts":{"dev":"tsup src/index.ts --format esm,cjs --dts --watch --external @sendgrid/mail","build":"tsup src/index.ts --format esm,cjs --dts --external @sendgrid/mail --tsconfig tsconfig.build.json","clean":"rm -rf dist","prepublishOnly":"npm run build"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"repository":{"url":"git+https://github.com/api-buddy/api-buddy.git#main","type":"git"},"_npmVersion":"9.8.1","description":"API Buddy integration for SendGrid - Email delivery service for transactional and marketing emails","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/core":"^0.4.108"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.8.3","@types/node":"^20.11.28","@types/react":"^18.3.23","@types/react-dom":"^19.1.6"},"peerDependencies":{"next":">=13.0.0","react":">=18.0.0","@sendgrid/mail":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sendgrid_0.4.108_1749659800665_0.8897035732134382","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"@api-buddy/sendgrid","version":"1.0.0","keywords":["sendgrid","email","transactional","marketing","nextjs","api"],"author":{"name":"API Buddy Team"},"license":"MIT","_id":"@api-buddy/sendgrid@1.0.0","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy/tree/main/packages/email/sendgrid#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-sendgrid":"cli.cjs"},"dist":{"shasum":"c8216df88d28ba03201772906c04823705cf7b42","tarball":"https://registry.npmjs.org/@api-buddy/sendgrid/-/sendgrid-1.0.0.tgz","fileCount":33,"integrity":"sha512-H7CIzhPTuShVUX06mU8S+2YvW3v3cMJObbu0+k13RpqyFBD44WkuQy8uNvAGivANO1DEp+H1+ViSCpRdBI4JDg==","signatures":[{"sig":"MEYCIQCm0Pgfaw8sBO5ALc+gx0HTNqPLPHyS+58v1X5d4nTvtwIhAPG/bB1OxLkAEx6fS/o9SdW10ofSaHo4IL77vwA7d12t","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":121308},"main":"dist/index.js","_from":"file:api-buddy-sendgrid-1.0.0.tgz","types":"dist/index.d.ts","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts,.tsx","test":"jest","build":"pnpm clean && tsup","clean":"rimraf dist","format":"prettier --write \"src/**/*.{ts,tsx}\"","prebuild":"node -e \"const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs'); let root = process.cwd(); while (root !== '/' && !fs.existsSync(path.join(root, 'pnpm-workspace.yaml'))) { root = path.dirname(root); } if (root === '/') { console.error('❌ Could not find project root directory'); process.exit(1); } require(path.join(root, 'scripts/ensure-tsup-config.js'));\"","type-check":"tsc --noEmit"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"_resolved":"/private/var/folders/w3/00m0j5k95zjfx4vwz3csj_vc0000gn/T/d3275cb23ef77d108857a43fafb13ab2/api-buddy-sendgrid-1.0.0.tgz","_integrity":"sha512-H7CIzhPTuShVUX06mU8S+2YvW3v3cMJObbu0+k13RpqyFBD44WkuQy8uNvAGivANO1DEp+H1+ViSCpRdBI4JDg==","repository":{"url":"git+https://github.com/api-buddy/api-buddy.git#main","type":"git"},"_npmVersion":"9.8.1","description":"API Buddy integration for SendGrid - Email delivery service for transactional and marketing emails","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/plugin-core":"1.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.5","typescript":"^5.8.3","@types/node":"^20.11.28","@types/react":"^18.3.23","@types/react-dom":"^19.1.6","@api-buddy/tsup-config":"1.0.0"},"peerDependencies":{"next":">=13.0.0","react":">=18.0.0","@sendgrid/mail":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sendgrid_1.0.0_1750087995312_0.1624423431504396","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@api-buddy/sendgrid","version":"2.0.0","keywords":["sendgrid","email","transactional","marketing","nextjs","api"],"author":{"name":"API Buddy Team"},"license":"MIT","_id":"@api-buddy/sendgrid@2.0.0","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"homepage":"https://github.com/api-buddy/api-buddy/tree/main/packages/email/sendgrid#readme","bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"bin":{"api-buddy-sendgrid":"cli.cjs"},"dist":{"shasum":"d6615ed378f1a464db90c459df76eab124b59299","tarball":"https://registry.npmjs.org/@api-buddy/sendgrid/-/sendgrid-2.0.0.tgz","fileCount":33,"integrity":"sha512-K8uMG55E1BWqOp0ThSMiOLpLG95FkY0btoFNXNBvBA23BDElxnSTXxL3RgrcaynBVNlkVu/P9zix7YQecQYmcA==","signatures":[{"sig":"MEYCIQD0sjtRQe8dgnMC11xRQRsdrqxTWQVcl3LRuGhs7dafbwIhAJrP+WGkjFl3fCe4UMARQQg3vrFF39cwCiY+Dwt8KOVR","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":121308},"main":"dist/index.js","_from":"file:api-buddy-sendgrid-2.0.0.tgz","types":"dist/index.d.ts","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts,.tsx","test":"jest","build":"pnpm clean && tsup","clean":"rimraf dist","format":"prettier --write \"src/**/*.{ts,tsx}\"","prebuild":"node -e \"const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs'); let root = process.cwd(); while (root !== '/' && !fs.existsSync(path.join(root, 'pnpm-workspace.yaml'))) { root = path.dirname(root); } if (root === '/') { console.error('❌ Could not find project root directory'); process.exit(1); } require(path.join(root, 'scripts/ensure-tsup-config.js'));\"","type-check":"tsc --noEmit"},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com"},"_resolved":"/private/var/folders/w3/00m0j5k95zjfx4vwz3csj_vc0000gn/T/87c388c882db3d4f9a27e3e5b4863d03/api-buddy-sendgrid-2.0.0.tgz","_integrity":"sha512-K8uMG55E1BWqOp0ThSMiOLpLG95FkY0btoFNXNBvBA23BDElxnSTXxL3RgrcaynBVNlkVu/P9zix7YQecQYmcA==","repository":{"url":"git+https://github.com/api-buddy/api-buddy.git#main","type":"git"},"_npmVersion":"9.8.1","description":"API Buddy integration for SendGrid - Email delivery service for transactional and marketing emails","directories":{},"_nodeVersion":"18.18.0","dependencies":{"@api-buddy/plugin-core":"2.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","rimraf":"^5.0.5","typescript":"^5.8.3","@types/node":"^20.11.28","@types/react":"^18.3.23","@types/react-dom":"^19.1.6","@api-buddy/tsup-config":"2.0.0"},"peerDependencies":{"next":">=13.0.0","react":">=18.0.0","@sendgrid/mail":"^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/sendgrid_2.0.0_1750103154723_0.7589127333887555","host":"s3://npm-registry-packages-npm-production"}},"3.0.0":{"name":"@api-buddy/sendgrid","version":"3.0.0","description":"API Buddy integration for SendGrid - Email delivery service for transactional and marketing emails","main":"dist/index.js","types":"dist/index.d.ts","peerDependencies":{"@sendgrid/mail":"^8.0.0","next":">=13.0.0","react":">=18.0.0"},"dependencies":{"@api-buddy/plugin-core":"3.0.0"},"devDependencies":{"@types/node":"^20.11.28","@types/react":"^18.3.23","@types/react-dom":"^19.1.6","tsup":"^8.0.0","typescript":"^5.8.3","rimraf":"^5.0.5","@api-buddy/tsup-config":"3.0.0"},"bin":{"api-buddy-sendgrid":"cli.cjs"},"keywords":["sendgrid","email","transactional","marketing","nextjs","api"],"author":{"name":"API Buddy Team"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/api-buddy/api-buddy.git#main"},"bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"homepage":"https://github.com/api-buddy/api-buddy/tree/main/packages/email/sendgrid#readme","publishConfig":{"access":"public"},"scripts":{"build":"pnpm clean && tsup","dev":"tsup --watch","clean":"rimraf dist","test":"jest","lint":"eslint src --ext .ts,.tsx","type-check":"tsc --noEmit","format":"prettier --write \"src/**/*.{ts,tsx}\"","prebuild":"node -e \"const { execSync } = require('child_process'); const path = require('path'); const fs = require('fs'); let root = process.cwd(); while (root !== '/' && !fs.existsSync(path.join(root, 'pnpm-workspace.yaml'))) { root = path.dirname(root); } if (root === '/') { console.error('❌ Could not find project root directory'); process.exit(1); } require(path.join(root, 'scripts/ensure-tsup-config.js'));\""},"_id":"@api-buddy/sendgrid@3.0.0","_integrity":"sha512-2hJ+uSzfqcam4KsR1xVd26tone27kt3QDemVJIlKyTLzEEZGU8uh7Xl0tS3IhbQpcXQSPyR9UVuvoEOS6GIPnQ==","_resolved":"/private/var/folders/w3/00m0j5k95zjfx4vwz3csj_vc0000gn/T/d98fe901816352ba7eddbe8d40541acf/api-buddy-sendgrid-3.0.0.tgz","_from":"file:api-buddy-sendgrid-3.0.0.tgz","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-2hJ+uSzfqcam4KsR1xVd26tone27kt3QDemVJIlKyTLzEEZGU8uh7Xl0tS3IhbQpcXQSPyR9UVuvoEOS6GIPnQ==","shasum":"5b34330f6fd54cc73ad26d4ec0e79b05c495101f","tarball":"https://registry.npmjs.org/@api-buddy/sendgrid/-/sendgrid-3.0.0.tgz","fileCount":33,"unpackedSize":121308,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGfmW2hATyH1Zpz8fM04Clo6kDL/YU8vIij+5E3mmSKmAiEA1JlFF8wORKnQfDiO2ot9oV3nhS2UGnVaiAFl3HidYLQ="}]},"_npmUser":{"name":"iamtomhanks","email":"brechanson@gmail.com","actor":{"name":"iamtomhanks","email":"brechanson@gmail.com","type":"user"}},"directories":{},"maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sendgrid_3.0.0_1751386871744_0.7631576352373539"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-09T02:32:22.023Z","modified":"2025-07-01T16:21:12.174Z","0.1.0":"2025-06-09T02:32:22.286Z","0.4.107":"2025-06-11T16:23:54.582Z","0.4.108":"2025-06-11T16:36:40.864Z","1.0.0":"2025-06-16T15:33:15.522Z","2.0.0":"2025-06-16T19:45:54.896Z","3.0.0":"2025-07-01T16:21:11.923Z"},"bugs":{"url":"https://github.com/api-buddy/api-buddy/issues"},"author":{"name":"API Buddy Team"},"license":"MIT","homepage":"https://github.com/api-buddy/api-buddy/tree/main/packages/email/sendgrid#readme","keywords":["sendgrid","email","transactional","marketing","nextjs","api"],"repository":{"type":"git","url":"git+https://github.com/api-buddy/api-buddy.git#main"},"description":"API Buddy integration for SendGrid - Email delivery service for transactional and marketing emails","maintainers":[{"name":"iamtomhanks","email":"brechanson@gmail.com"}],"readme":"# @api-buddy/sendgrid\r\n\r\n[![npm version](https://img.shields.io/npm/v/@api-buddy/sendgrid.svg)](https://www.npmjs.com/package/@api-buddy/sendgrid)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\r\n\r\nA comprehensive SendGrid integration for Next.js applications, providing a simple and type-safe way to send transactional and marketing emails.\r\n\r\n## Features\r\n\r\n- 🚀 **Easy Setup**: Get started quickly with a few simple steps\r\n- 🔒 **Type-Safe**: Full TypeScript support for all email options and responses\r\n- ⚡ **Performance Optimized**: Efficient email sending with proper error handling\r\n- 🎣 **React Hooks**: Custom hooks for easy email sending from React components\r\n- 🛠 **CLI Tool**: Quick project setup with the included CLI\r\n- 📧 **Templates Support**: Built-in support for SendGrid's dynamic templates\r\n- 📊 **Analytics**: Track email opens, clicks, and other events\r\n\r\n## Installation\r\n\r\n```bash\r\n# Using npm\r\nnpm install @api-buddy/sendgrid @sendgrid/mail\r\n\r\n# Using yarn\r\nyarn add @api-buddy/sendgrid @sendgrid/mail\r\n\r\n# Using pnpm\r\npnpm add @api-buddy/sendgrid @sendgrid/mail\r\n```\r\n\r\n## Quick Start\r\n\r\n### 1. Set Up Environment Variables\r\n\r\nCreate a `.env.local` file in your project root and add your SendGrid API key:\r\n\r\n```env\r\nSENDGRID_API_KEY=your_sendgrid_api_key_here\r\nSENDGRID_FROM_EMAIL=your-email@example.com\r\n```\r\n\r\n### 2. Initialize SendGrid in Your Next.js App\r\n\r\nWrap your application with the `SendGridProvider` in your root layout:\r\n\r\n```tsx\r\n// app/layout.tsx\r\n'use client';\r\n\r\nimport { SendGridProvider } from '@api-buddy/sendgrid';\r\n\r\nexport default function RootLayout({\r\n  children,\r\n}: {\r\n  children: React.ReactNode;\r\n}) {\r\n  return (\r\n    <html lang=\"en\">\r\n      <body>\r\n        <SendGridProvider \r\n          config={{\r\n            // Optional: Configure default settings here\r\n            defaultFrom: 'noreply@yourdomain.com',\r\n            defaultReplyTo: 'support@yourdomain.com',\r\n          }}\r\n        >\r\n          {children}\r\n        </SendGridProvider>\r\n      </body>\r\n    </html>\r\n  );\r\n}\r\n```\r\n\r\n### 3. Send Your First Email\r\n\r\nCreate an API route to handle email sending:\r\n\r\n```typescript\r\n// app/api/email/route.ts\r\nimport { NextResponse } from 'next/server';\r\nimport { sendEmail } from '@api-buddy/sendgrid';\r\n\r\nexport async function POST(request: Request) {\r\n  try {\r\n    const { to, subject, text, html } = await request.json();\r\n    \r\n    const result = await sendEmail({\r\n      to,\r\n      from: 'noreply@yourdomain.com',\r\n      subject,\r\n      text,\r\n      html,\r\n    });\r\n    \r\n    return NextResponse.json({ success: true, data: result });\r\n  } catch (error) {\r\n    console.error('Error sending email:', error);\r\n    return NextResponse.json(\r\n      { success: false, error: 'Failed to send email' },\r\n      { status: 500 }\r\n    );\r\n  }\r\n}\r\n```\r\n\r\n### 4. Use the useEmail Hook in Your Components\r\n\r\n```tsx\r\n'use client';\r\n\r\nimport { useEmail } from '../hooks/useEmail';\r\n\r\nexport function ContactForm() {\r\n  const { sendEmail, isLoading, error } = useEmail();\r\n  \r\n  const handleSubmit = async (e: React.FormEvent) => {\r\n    e.preventDefault();\r\n    \r\n    try {\r\n      await sendEmail({\r\n        to: 'contact@yourdomain.com',\r\n        subject: 'New Contact Form Submission',\r\n        text: 'Hello from the contact form!',\r\n        html: '<p>Hello from the contact form!</p>',\r\n      });\r\n      \r\n      alert('Message sent successfully!');\r\n    } catch (err) {\r\n      console.error('Failed to send message:', err);\r\n      alert('Failed to send message. Please try again.');\r\n    }\r\n  };\r\n  \r\n  return (\r\n    <form onSubmit={handleSubmit}>\r\n      {/* Your form fields */}\r\n      <button type=\"submit\" disabled={isLoading}>\r\n        {isLoading ? 'Sending...' : 'Send Message'}\r\n      </button>\r\n      {error && <div className=\"error\">{error.message}</div>}\r\n    </form>\r\n  );\r\n}\r\n```\r\n\r\n## CLI Setup\r\n\r\nFor a quick setup, use the included CLI:\r\n\r\n```bash\r\nnpx @api-buddy/sendgrid\r\n```\r\n\r\nThis will:\r\n1. Install required dependencies\r\n2. Create an API route for sending emails\r\n3. Generate a custom `useEmail` hook\r\n4. Set up an example contact form component\r\n5. Update your environment variables\r\n\r\n## API Reference\r\n\r\n### `SendGridProvider`\r\n\r\nA context provider that makes the SendGrid client available throughout your application.\r\n\r\n#### Props\r\n\r\n- `config`: Configuration object\r\n  - `apiKey`: Your SendGrid API key (optional, defaults to `process.env.SENDGRID_API_KEY`)\r\n  - `defaultFrom`: Default \"from\" email address\r\n  - `defaultReplyTo`: Default \"reply to\" email address\r\n  - `mailSettings`: Default mail settings for all emails\r\n  - `trackingSettings`: Default tracking settings for all emails\r\n  - `asm`: Default ASM (Advanced Suppression Manager) settings\r\n  - `ipPoolName`: Default IP pool name\r\n\r\n### `useSendGrid()`\r\n\r\nA hook to access the SendGrid client and config from the nearest `SendGridProvider`.\r\n\r\n#### Returns\r\n\r\n- `client`: The SendGrid client instance\r\n- `config`: The current SendGrid configuration\r\n\r\n### `sendEmail(options: EmailOptions): Promise<SendGridResponse>`\r\n\r\nSend an email using SendGrid.\r\n\r\n#### Parameters\r\n\r\n- `options`: Email options\r\n  - `to`: Recipient email address or array of email addresses\r\n  - `from`: Sender email address\r\n  - `subject`: Email subject\r\n  - `text`: Plain text content\r\n  - `html`: HTML content\r\n  - `templateId`: SendGrid template ID\r\n  - `dynamicTemplateData`: Dynamic template data\r\n  - `attachments`: Email attachments\r\n  - `categories`: Email categories for tracking\r\n  - `customArgs`: Custom arguments\r\n  - `headers`: Custom headers\r\n  - `mailSettings`: Mail settings\r\n  - `trackingSettings`: Tracking settings\r\n  - `replyTo`: Reply-to email address\r\n  - `sendAt`: Send at timestamp (Unix timestamp)\r\n  - `batchId`: Batch ID for scheduling\r\n  - `asm`: ASM (Advanced Suppression Manager) settings\r\n  - `ipPoolName`: IP pool name\r\n\r\n#### Returns\r\n\r\nA promise that resolves to the SendGrid API response.\r\n\r\n### `useEmail()`\r\n\r\nA hook for sending emails from React components.\r\n\r\n#### Returns\r\n\r\n- `sendEmail`: Function to send an email\r\n- `isLoading`: Boolean indicating if an email is being sent\r\n- `error`: Error object if sending failed\r\n- `reset`: Function to reset the hook state\r\n\r\n## Examples\r\n\r\n### Sending a Simple Email\r\n\r\n```typescript\r\nimport { sendEmail } from '@api-buddy/sendgrid';\r\n\r\n// In an API route or server component\r\nawait sendEmail({\r\n  to: 'recipient@example.com',\r\n  from: 'sender@example.com',\r\n  subject: 'Hello from SendGrid',\r\n  text: 'This is a test email',\r\n  html: '<p>This is a test email</p>',\r\n});\r\n```\r\n\r\n### Using Dynamic Templates\r\n\r\n```typescript\r\nawait sendEmail({\r\n  to: 'recipient@example.com',\r\n  from: 'sender@example.com',\r\n  templateId: 'd-1234567890abcdef1234567890abcdef',\r\n  dynamicTemplateData: {\r\n    name: 'John Doe',\r\n    verificationLink: 'https://example.com/verify?token=abc123',\r\n  },\r\n});\r\n```\r\n\r\n### Sending to Multiple Recipients\r\n\r\n```typescript\r\nawait sendEmail({\r\n  to: ['user1@example.com', 'user2@example.com'],\r\n  from: 'sender@example.com',\r\n  subject: 'Hello everyone!',\r\n  text: 'This email is sent to multiple recipients',\r\n});\r\n```\r\n\r\n## Error Handling\r\n\r\nAll email sending methods throw a `SendGridApiError` when something goes wrong. You can catch and handle these errors:\r\n\r\n```typescript\r\ntry {\r\n  await sendEmail({\r\n    // ...\r\n  });\r\n} catch (error) {\r\n  if (error.isRateLimit) {\r\n    console.error('Rate limit exceeded:', error.message);\r\n  } else if (error.isAuthError) {\r\n    console.error('Authentication error:', error.message);\r\n  } else {\r\n    console.error('Error sending email:', error.message);\r\n  }\r\n}\r\n```\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please open an issue or submit a pull request.\r\n\r\n## License\r\n\r\nMIT\r\n\r\n## Acknowledgments\r\n\r\n- [SendGrid](https://sendgrid.com/) - Email delivery service\r\n- [@sendgrid/mail](https://www.npmjs.com/package/@sendgrid/mail) - Official SendGrid Node.js library\r\n","readmeFilename":"README.md"}