trywind
A lightweight browser library for Wind Connect flows — redirect, popup, and URL parsing.
Install
shell
npm install trywind
Or via CDN (no build step):
html
<script src="https://wind-production-3225.up.railway.app/wind.js"></script>
Initialize
typescript
const wind = new WindManager({
appId: 'YOUR_APP_ID', // required
appName: 'My App', // shown in Wind Connect UI
}) connect(options)
Redirects to Wind Connect (link mode) or opens a popup. Defaults to link mode.
typescript
wind.connect({
externalUserId: currentUser.id,
mode: 'link', // 'link' (default) or 'popup'
returnUrl: window.location.href,
}) connectPopup(options)
Opens a popup and returns a Promise that resolves when the user connects.
typescript
try {
const result = await wind.connectPopup({ externalUserId: currentUser.id })
await saveToBackend(result.windUserId)
} catch (err) {
if (err.message === 'wind_denied') console.log('User clicked Deny')
if (err.message === 'popup_closed') console.log('Closed without connecting')
if (err.message === 'connect_timeout')console.log('Timed out (5 min)')
} parseReturnUrl()
Call on page load after a link-mode redirect.
typescript
const result = wind.parseReturnUrl()
if (result?.connected) {
await saveToBackend(result.windUserId)
} else if (result?.error === 'denied') {
showToast('Connection cancelled.')
} Other methods
wind.getStoredUserId() Read wind_user_id from localStorage. wind.isConnected() Returns true if a wind_user_id is stored. wind.disconnect() Removes wind_user_id from localStorage. wind-manager-ios
Swift Package for iOS Wind Connect. Uses ASWebAuthenticationSession, stores the user ID in the Keychain. Requires iOS 16+.
Installation
In Xcode: File → Add Package Dependencies and paste:
shell
https://github.com/edwin-ma26/wind-manager-ios
swift
import WindManager let wind = WindManager(appId: "YOUR_APP_ID", appName: "Your App")
connect(from:callbackScheme:externalUserId:forceAuth:)
Register your URL scheme in
Info.plist under CFBundleURLTypes.
swift
let result = try await wind.connect(
from: self,
callbackScheme: "myapp",
externalUserId: currentUser.id
)
// result.windUserId, result.windEmail, result.balanceCents Other methods
wind.getStoredUserId() Read Wind user ID from Keychain. wind.isConnected() Returns true if a Wind user ID is stored. wind.disconnect() Removes the Wind user ID from the Keychain. WindError
.cancelled User dismissed the Wind Connect sheet. .denied User clicked "Deny" in Wind Connect. .missingCallback Wind Connect completed but returned no valid callback URL. .invalidURL Could not construct the Wind Connect URL. .notConnected balance() was called but no Wind user ID is in the Keychain. .sessionError(Error) An underlying ASWebAuthenticationSession error. Wind CLI
Manage features from your terminal.
Install
shell
npm install -g trywind-cli wind login
Features
shell
wind features list wind features create feat_chat --name "AI Chat" --price 0.05 wind features create feat_chat \ --pricing-model per_token --multiplier 1.5 --model google/gemini-2.5-flash wind features update feat_chat --price 0.08 wind features delete feat_chat --yes