C&C Docs
Log in
Pages

Using a module

A module is a package of widgets, layouts, pages and code that other apps can use. Add it to deps in your app's cnc.json and its widgets are yours to write, with nothing copied. This site takes one module, @clickncode.com/cnc-widgets. Only the names a module lists in its catalog are public; the rest stays private to it.

// cnc.json
{
  "name": "@clickncode.com/docs",
  "deps": ["@clickncode.com/cnc-widgets@^0.1.0"]
}
from cnc-widgets
<cnc-badge label="from cnc-widgets"></cnc-badge>

Import a module's file by name

A controller can import a module's code by the module's name. The server renders the count below from the imported file; the browser imports the same file to filter as you type.

import { COUNTRY_CODES } from '@clickncode.com/cnc-widgets/widgets/countries.mjs'
195 countries.
195 match
  • Afghanistan
  • Albania
  • Algeria
  • Andorra
  • Angola
  • Antarctica
  • Antigua and Barbuda
  • Argentina
  • Armenia
  • Australia
  • Austria
  • Azerbaijan