[{"data":1,"prerenderedAt":435},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit":3},{"id":4,"title":5,"body":6,"description":417,"extension":418,"frontmatter":419,"heading":5,"meta":426,"navigation":428,"order":423,"path":429,"seo":430,"sitemap":431,"source":432,"stem":433,"__hash__":434},"docs\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit.md","kubb init",{"type":7,"value":8,"toc":409},"minimark",[9,21,26,29,51,54,97,100,130,141,159,173,196,200,323,334,338,341,353,356,374,403],[10,11,12,13,16,17,20],"p",{},"Run ",[14,15,5],"code",{}," for an interactive setup wizard. Kubb looks at your project first, asks a few questions, shows the config for review, then installs your chosen plugins, writes ",[14,18,19],{},"kubb.config.ts",", and runs the first generation.",[22,23,25],"h2",{"id":24},"usage","Usage",[10,27,28],{},"Run the command in the directory where your Kubb project lives:",[30,31,36],"pre",{"language":32,"filename":33,"code":34,"class":35},"shell","Terminal","npx kubb init","highlights",[14,37,39],{"class":38},"language-shell",[40,41,44,48],"span",{"class":42,"style":43},"line","display: inline",[40,45,47],{"style":46},"color:#6f42c1;--hls-dark:#b392f0","npx ",[40,49,5],{"style":50},"color:#24292e;--hls-dark:#e1e4e8",[10,52,53],{},"Before the first question, Kubb detects:",[55,56,57,76],"ul",{},[58,59,60,61,64,65,64,68,71,72,75],"li",{},"The package manager (",[14,62,63],{},"bun",", ",[14,66,67],{},"pnpm",[14,69,70],{},"npm",", or ",[14,73,74],{},"yarn",").",[58,77,78,79,82,83,86,87,64,90,64,93,96],{},"OpenAPI and Swagger files in the repo, such as ",[14,80,81],{},"openapi.yaml"," or ",[14,84,85],{},"api\u002Fswagger.json",", up to three folders deep. It skips ",[14,88,89],{},"node_modules",[14,91,92],{},"dist",[14,94,95],{},"build",", and hidden folders, and shows the version and operation count of the first one.",[10,98,99],{},"The wizard then asks for three things:",[55,101,102,105,123],{},[58,103,104],{},"Which spec to read: a file it found, a URL, or another file.",[58,106,107,108,113,114,118,119,122],{},"Which ",[109,110,112],"a",{"href":111},"\u002Fextensions\u002Fkind\u002Fplugins","plugins"," to add. The list comes from the ",[109,115,117],{"href":116},"\u002Fdocs\u002F5.x\u002Freference\u002Fregistry","Kubb registry",", with ",[14,120,121],{},"plugin-ts"," selected by default. Choose the plugins you need; the CLI does not infer them from your framework or installed libraries. Plugin manifests declare which dependencies a selection requires.",[58,124,125,126,129],{},"The output folder, ",[14,127,128],{},".\u002Fsrc\u002Fgen"," by default.",[10,131,132,133,135,136,140],{},"Kubb then shows the full ",[14,134,19],{}," and the packages it installs. Pick ",[137,138,139],"strong",{},"Change a choice"," to answer the questions again.",[10,142,143,144,146,147,150,151,154,155,158],{},"After you confirm, Kubb installs the packages, writes ",[14,145,19],{},", and adds ",[14,148,149],{},"\"generate\": \"kubb generate\""," to the ",[14,152,153],{},"package.json"," scripts when there is no ",[14,156,157],{},"generate"," script yet. It never changes an existing one. Then it runs the first generation. When that run fails, Kubb shows the error, keeps the setup, and exits with code 1.",[10,160,161,162,165,166,172],{},"Kubb installs ",[14,163,164],{},"kubb"," at the exact version of the CLI you ran. Each plugin is added the way ",[109,167,169],{"href":168},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Fadd",[14,170,171],{},"kubb add"," adds it: at the version the registry pins, and only when it supports the running Kubb and Node.js versions.",[10,174,175,176,180,181,184,185,188,189,192,193,195],{},"Before it installs anything, Kubb checks the ",[109,177,179],{"href":178},"\u002Fdocs\u002F5.x\u002Freference\u002Fkit\u002Fmanifest","manifest"," of each chosen plugin. If a plugin's ",[14,182,183],{},"dependencies"," are not all chosen, or a plugin with ",[14,186,187],{},"role: \"consumer\""," (such as ",[14,190,191],{},"plugin-react-query",") has no client plugin next to it, ",[14,194,5],{}," names what is missing and stops.",[22,197,199],{"id":198},"options","Options",[201,202,203,219],"table",{},[204,205,206],"thead",{},[207,208,209,213,216],"tr",{},[210,211,212],"th",{},"Option",[210,214,215],{},"Default",[210,217,218],{},"Description",[220,221,222,251,266,281,309],"tbody",{},[207,223,224,233,238],{},[225,226,227,64,230],"td",{},[14,228,229],{},"--yes",[14,231,232],{},"-y",[225,234,235],{},[14,236,237],{},"false",[225,239,240,241,244,245,247,248,250],{},"Skip all prompts and the review. Uses the first spec found (or ",[14,242,243],{},".\u002Fopenapi.yaml","), ",[14,246,121],{},", and ",[14,249,128],{},", and prints one line per step.",[207,252,253,261,263],{},[225,254,255,64,258],{},[14,256,257],{},"--input",[14,259,260],{},"-i",[225,262],{},[225,264,265],{},"Path to the OpenAPI specification (local file or URL). Bypasses the spec path prompt.",[207,267,268,276,278],{},[225,269,270,64,273],{},[14,271,272],{},"--output",[14,274,275],{},"-o",[225,277],{},[225,279,280],{},"Output directory for generated files. Bypasses the output directory prompt.",[207,282,283,288,290],{},[225,284,285],{},[14,286,287],{},"--plugins",[225,289],{},[225,291,292,293,297,298,301,302,305,306,308],{},"Comma-separated registry ids of the plugins to add, the same ids ",[109,294,295],{"href":168},[14,296,171],{}," takes, such as ",[14,299,300],{},"plugin-ts,plugin-zod",", or short names such as ",[14,303,304],{},"ts,zod",". Bypasses the plugin selection prompt. An id that is not in the registry stops ",[14,307,5],{},".",[207,310,311,316,320],{},[225,312,313],{},[14,314,315],{},"--dry-run",[225,317,318],{},[14,319,237],{},[225,321,322],{},"Preview the wizard without installing packages, writing files, or running the first generation.",[10,324,325,326,328,329,331,332,308],{},"Each flag skips only its own prompt and combines with ",[14,327,229],{},". Pass all three value flags to skip the choice prompts and review. If ",[14,330,19],{}," already exists, Kubb still asks before overwriting it unless you pass ",[14,333,229],{},[22,335,337],{"id":336},"examples","Examples",[10,339,340],{},"Run with the defaults and no prompts:",[30,342,344],{"language":32,"filename":33,"code":343,"class":35},"npx kubb init --yes",[14,345,346],{"class":38},[40,347,348,350],{"class":42,"style":43},[40,349,47],{"style":46},[40,351,352],{"style":50},"kubb init --yes",[10,354,355],{},"Run with no prompts and a specific spec, output directory, and plugins:",[30,357,359],{"language":32,"filename":33,"code":358,"class":35},"npx kubb init --yes --input .\u002Fopenapi.yaml --plugins ts,zod --output src\u002Fapi",[14,360,361],{"class":38},[40,362,363,365,368,371],{"class":42,"style":43},[40,364,47],{"style":46},[40,366,367],{"style":50},"kubb init --yes --input .\u002Fopenapi.yaml --plugins ts",[40,369,370],{"style":50},",",[40,372,373],{"style":50},"zod --output src\u002Fapi",[30,375,379],{"language":376,"filename":377,"code":378,"class":35},"text","Output","✓ Installed kubb @kubb\u002Fplugin-ts @kubb\u002Fplugin-zod with npm\n✓ Wrote kubb.config.ts\n✓ Generated 84 files in src\u002Fapi\nKubb is set up. Run npm run generate after changing the spec.",[14,380,382,387,388,387,393,387,398],{"class":381},"language-text",[40,383,384],{"class":42,"style":43},[40,385,386],{"style":50},"✓ Installed kubb @kubb\u002Fplugin-ts @kubb\u002Fplugin-zod with npm","\n",[40,389,390],{"class":42,"style":43},[40,391,392],{"style":50},"✓ Wrote kubb.config.ts",[40,394,395],{"class":42,"style":43},[40,396,397],{"style":50},"✓ Generated 84 files in src\u002Fapi",[40,399,400],{"class":42,"style":43},[40,401,402],{"style":50},"Kubb is set up. Run npm run generate after changing the spec.",[10,404,405,406,408],{},"Add ",[14,407,315],{}," to preview what the wizard would install and write.",{"title":410,"searchDepth":411,"depth":411,"links":412},"",5,[413,415,416],{"id":24,"depth":414,"text":25},2,{"id":198,"depth":414,"text":199},{"id":336,"depth":414,"text":337},"The init command bootstraps a fresh Kubb project with an interactive wizard.","md",{"layout":420,"title":5,"description":417,"outline":421,"order":423,"navigation":424},"doc",[414,422],3,1,{"title":5,"icon":425},"i-iconoir-magic-wand",{"layout":420,"outline":427},[414,422],{"title":5,"icon":425},"\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit",{"title":5,"description":417},{"loc":429},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Freference\u002Fcommands\u002Finit.md","docs\u002F5.x\u002Freference\u002Fcommands\u002Finit","qcixPt6IBBWTl6GabPJcsRNN8CRdIWIzwvGcumGGaXg",1792850406241]