Apple Wallet Integration with Node.js and pkpass
Introduction
Apple Wallet (PassKit) enables users to store event tickets, passes, and boarding passes directly on their iPhones for instant access. In this guide, we'll cover how to integrate Apple Wallet into your Node.js application using .pkpass files and the passkit-generator package.
We'll go step by step: from setting up certificates in Apple Developer Portal to generating passes and delivering them to users.
How Apple Wallet Passes Work
An Apple Wallet pass (.pkpass) is simply a zipped bundle containing:
pass.json— metadata (event info, barcodes, colors)- Images (icon, logo, strip, background)
manifest.json— list of files with hashessignature— signed with your Apple certificate
Step 1: Create a Pass Type ID and Certificate
- Log in to Apple Developer Account.
- Create a Pass Type ID (Certificates, Identifiers & Profiles → Identifiers → Pass Type IDs), enter a description and identifier, and save.
- Create a Certificate for the Pass Type ID. Generate a Certificate Signing Request (CSR) from your Mac:
openssl req -new -newkey rsa:2048 -nodes -keyout pass.key -out pass.csrUpload the CSR to the Apple Developer portal, then download the generated certificate (.cer).
- Export the certificate to
.p12format: double-click the.certo install into Keychain Access, find it under My Certificates, right-click → Export, save as.p12, and set a password (you'll use this in Node.js). - Download the Apple WWDR Certificate and convert it to
.pemformat:
openssl x509 -in AppleWWDRCAG3.cer -inform DER -out wwdr.pem -outform PEMAt this point, you have:
pass.p12→ Pass Type Certificate (with password)wwdr.pem→ Apple WWDR certificatepass.key→ private key
These will be used to sign your passes in Node.js.
Step 2: Install Dependencies
We'll use passkit-generator.
npm install passkit-generatorStep 3: Create a Pass in Node.js
import { PKPass } from "passkit-generator";
import fs from "fs";
// Load certificates
const cert = fs.readFileSync("./certs/pass.p12");
const wwdr = fs.readFileSync("./certs/wwdr.pem");
const password = "your-cert-password";
// Create pass
const pass = new PKPass({
model: "./eventPass", // folder containing pass.json + images
certificates: {
wwdr,
signerCert: cert,
signerKeyPassphrase: password,
},
}, {
serialNumber: "TICKET12345",
description: "Concert Ticket",
});
// Add details
pass.fields.primaryFields.add("event", "Concert Night", "Gate Opens 7 PM");
pass.fields.secondaryFields.add("venue", "Sunshine Arena");
// Add QR code
pass.setBarcodes({
message: "TICKET12345",
format: "PKBarcodeFormatQR",
});
// Save pass
fs.writeFileSync("event-ticket.pkpass", pass.getAsBuffer());Step 4: Deliver the Pass to Users
- Serve
.pkpassvia download link or email attachment. - On iOS → "Add to Wallet" prompt appears.
- On Android → Gmail/Chrome detect
.pkpassand allow opening.
Step 5: Validate and Test
- Use Apple's Pass Validator to check correctness.
- Test on multiple iOS devices and versions.
Conclusion
By creating a Pass Type ID and certificates in the Apple Developer portal, then generating .pkpass files in Node.js, you can integrate Apple Wallet support into your ticketing system and deliver a seamless user experience.