init
Set up Voidhash in your project with a one-time interactive command.
voidhash-cli init is the one-time setup command for a React Native project. It signs you in,
lets you pick (or create) a team and project, verifies the project has a publishable key, and
scaffolds the three files your app needs: voidhash.config.ts, an SDK client module with the key
pre-filled, and the initial voidhash.gen.d.ts type declarations.
Run it in the root of your Expo / React Native project:
npx voidhash-cli initThe command takes no flags. Everything is resolved interactively.
What happens when you run it
Overwrite check
If a voidhash.config.ts (or .js) already exists, init asks whether to overwrite the existing
configuration. Confirming deletes the old config file and starts fresh; declining prints
Initialization cancelled. and exits without touching anything.
Sign in
If you are not logged in, init asks for confirmation and then opens a browser window to sign you
in — the same flow as voidhash-cli auth login. If you are already logged in,
this step is skipped.
Select a team and project
You pick the team (organization) and then one of its projects from an interactive list. Both prompts include an option to create a new one inline, so a fresh account can go from zero to a configured project without leaving the terminal.
Publishable key check
init verifies that the selected project has a publishable API key (vh_pk_...). The key is not
stored in any config file — it goes straight into the generated SDK client module in the next
step. If no valid publishable key exists, the command fails with
Could not retrieve a valid publishable key for the selected project. — create one in the
dashboard and re-run init.
Files are written
init detects whether your project uses TypeScript or JavaScript and whether it has a src/
directory, then writes the files described below. It refuses to overwrite anything unexpected —
each target path is checked before writing.
What gets written
voidhash.config.ts
The project configuration, written to the project root (as .js in JavaScript projects):
import { defineConfig } from 'voidhash-cli';
export default defineConfig({
team: 'acme',
project: 'my-app',
});team and project are the slugs you selected. This file is consumed by
voidhash-cli types and voidhash-cli deploy. A third
option, typesOutput, controls where the generated declaration file is written — init omits it
so the default (voidhash.gen.d.ts at the project root) applies.
src/lib/voidhash.ts
The SDK client module, with your publishable key pre-filled so it works on the first run. In
projects without a src/ directory it is written to lib/voidhash.js instead:
import { createVoidhashClient } from "@voidhash/react-native";
/**
* Voidhash SDK client. Safe to edit.
*
* Use it like `<voidhash.Provider>` and `voidhash.useProducts()`. The
* publishable key is safe to ship in client code.
*/
export const voidhash = createVoidhashClient("vh_pk_...");The file is yours to edit — the rest of your app imports the voidhash object from here, e.g.
<voidhash.Provider> or voidhash.useProducts().
voidhash.gen.d.ts
The initial TypeScript declaration file, generated from your project's schema on the server so
autocomplete works immediately. It embeds a schema version header used by
voidhash-cli types check to detect drift.
Types generation is non-fatal
If fetching the remote schema fails, init logs a warning and finishes anyway. Run
voidhash-cli types generate later to produce the declaration file.
Next steps
On success, init prints where each file was written and these next steps:
- Wrap your app with
<voidhash.Provider>from the generated client module. - Create your products and paywall locations in the Voidhash dashboard.
- Re-run
voidhash-cli types generatewhenever the dashboard schema changes.
No local schema files
Voidhash is server-first: the dashboard is the source of truth for products, paywall locations,
and the rest of your schema. init does not generate any local schema files — you define your
catalog in the dashboard and pull its shape into your editor with voidhash-cli types generate.