Address Verification
Terra integrates with Smarty Streets to provide address autocomplete and USPS validation. This ensures accurate addresses for mail delivery—critical for government benefit programs.How It Works
1
User Starts Typing
After 3 characters, address suggestions appear in real-time.
2
User Selects Suggestion
All address fields auto-populate with the standardized address:
- Street:
123 Main Street - City:
Seattle - State:
WA - ZIP:
98101
3
Manual Override (Optional)
If the user manually edits any field, the badge changes to ⚠ Unverified.This allows flexibility while clearly indicating validation status.
Required Smarty Products
Smarty sells different API products separately. For full functionality:| Product | What It Does | Price |
|---|---|---|
| US Autocomplete Pro | Type-ahead suggestions | $21/month (5,000 lookups) |
| US Address Verification | USPS validation | Free tier: 250/month |
Without Autocomplete Pro, the address field still works—users just type manually without suggestions. The verification badge will not appear.
Setup
1. Create a Smarty Account
- Go to smarty.com
- Sign up for an account
- Purchase US Autocomplete Pro subscription (if you want autocomplete)
- US Address Verification is included free
2. Get API Credentials
- Go to Dashboard → API Keys
- Copy your Auth ID and Auth Token
3. Configure Environment Variables
Add to your.env.local:
4. Restart the Dev Server
Testing the Integration
Run the test script to verify your credentials:Using the Address Field
In the Form Builder
- Add an Address field from the field palette
- Configure options:
- Include Unit: Add apartment/suite field
- Required: Make the field mandatory
In Public Forms
The address field automatically:- Shows autocomplete when Smarty is configured
- Falls back to manual entry when not configured
- Displays verification status badges
Verification States
| Badge | Meaning |
|---|---|
| ✓ Verified | User selected from autocomplete suggestions |
| ⚠ Unverified | User typed manually or edited after selection |
| (No badge) | Address field is empty |
Stored Data
The address field saves the following structure:verified flag lets admins filter submissions by address quality.
Architecture
Server Actions
Address operations use Next.js Server Actions for security:Component
Hydration Safety
The address field uses client-side mounting to prevent hydration mismatches with Radix UI:Common Issues
Autocomplete not showing suggestions
Autocomplete not showing suggestions
- Verify you have US Autocomplete Pro subscription (not just verification)
- Run
npx tsx scripts/test-smarty.tsto check credentials - Check browser console for errors
- Ensure you’re typing at least 3 characters
402 Payment Required error
402 Payment Required error
Your Smarty account needs an active US Autocomplete Pro subscription.US Address Verification (free tier) only validates complete addresses—it doesn’t provide autocomplete.
Hydration mismatch errors
Hydration mismatch errors
If you see React hydration warnings with the address field, ensure:
- The
mountedstate pattern is in place - Radix UI components render only after mount
- SSR renders a placeholder, not the full Popover/Select
Works in test script but not in app
Works in test script but not in app
The test script uses direct HTTP calls. If autocomplete works in the script but not the app:
- Restart your dev server to pick up new env vars
- Check that
.env.localis in the project root - Verify the server action is being called (check Network tab)
Without Smarty Streets
Address fields work without Smarty configuration:- Users type addresses manually
- No autocomplete suggestions
- No verification badges
- Data still saves correctly
- Development without API keys
- Forms where verification isn’t critical
- International addresses (Smarty is US-only)
Next: Adding Custom Fields
Learn how to extend the form engine with new field types.