BlogWork With Me →

License & Setup

All Pro components require a valid license key. Wrap your app with FieldCraftProProvider to enable them.

Install

npm install @squaredr/fieldcraft-pro

Provider Setup

Wrap the part of your app that uses Pro components with the provider. Pass your license key via an environment variable:

app/providers.tsx
import { FieldCraftProProvider } from "@squaredr/fieldcraft-pro";

export function Providers({ children }: { children: React.ReactNode }) {
return (
<FieldCraftProProvider
licenseKey={process.env.NEXT_PUBLIC_FCPRO_LICENSE_KEY!}
>
{children}
</FieldCraftProProvider>
);
}

Environment variable: Add NEXT_PUBLIC_FCPRO_LICENSE_KEY=your-key-here to your .env file. Never commit license keys to version control.

How It Works

When a Pro component mounts, it checks the nearest FieldCraftProProvider for a valid license. If the key is missing or invalid, the component renders with a watermark overlay.

  • Valid key — component renders normally
  • Invalid or expired key — component renders with a watermark
  • No provider — component renders with a watermark

Checking License Status

Use the useLicense hook to read the current license status from any component inside the provider:

import { useLicense } from "@squaredr/fieldcraft-pro";

function MyComponent() {
const { status, tier } = useLicense();

if (status === "valid") {
return <p>Licensed: {tier} tier</p>;
}

return <p>No valid license</p>;
}

Exports

ExportTypeDescription
FieldCraftProProviderComponentLicense context provider
useLicenseHookReturns status and tier
requireLicenseHOCWraps a component with license enforcement
validateLicenseFunctionValidates a license key string
tierHasFeatureFunctionCheck if a tier includes a feature
UnlicensedWatermarkComponentWatermark overlay for unlicensed components