/connect-ckan
/connect-ckan connects an existing PortalJS portal to a live CKAN
backend. The portal stops reading static files from /public/data/ and instead
lists and renders datasets straight from a CKAN instance's REST API
(package_search / package_show) using the @portaljs/ckan client. The output
is plain, editable Next.js code — no opaque framework wiring.
When to use it
Use it for the decoupled / any-backend path: you have a CKAN data management
system (your own or a public one) and want a browseable portal in front of it.
CKAN calls run server-side in getStaticProps / getStaticPaths, so the
@portaljs/ckan bundle never reaches the browser and the site can still be
statically deployed.
Inputs
| Input | Required | Notes |
|---|---|---|
| CKAN base URL | Yes | The root of the instance, e.g. https://demo.dev.datopian.com. Must be publicly reachable. |
| Org filter | No | One or more CKAN organization names to restrict the catalog to. |
| Group filter | No | One or more CKAN group names to restrict the catalog to. |
| Portal directory | No | Path to the portal project. Defaults to the current directory. |
The skill verifies the CKAN API is reachable (and that any named orgs exist) before generating code.
Example
/connect-ckan https://demo.dev.datopian.com
Restricted to specific organizations:
/connect-ckan https://demo.dev.datopian.com --org transport,environment
What it produces
@portaljs/ckanadded topackage.json, plus atsconfig.jsonpathsentry so TypeScript resolves the client's types.lib/ckan.ts— a small, editable client module. The CKAN URL is the default, overridable at deploy time via theDMSenv var; org/group filters and a build-time page cap (MAX_DATASETS) are plain constants you can edit.pages/index.tsxrewritten to list datasets frompackage_search.pages/datasets/[slug].tsx— a dynamic route that pre-renders one page per dataset viapackage_show, previewing CSV/TSV resources through the template'sTable.
It verifies the build before reporting success. When it finishes:
✓ Connected to CKAN: https://demo.dev.datopian.com
- Client: lib/ckan.ts (DMS overridable via env var)
- Home: pages/index.tsx → lists datasets from package_search
- Dataset: pages/datasets/[slug].tsx → package_show, CSV/TSV preview via <Table>
The default is static generation (data fixed at build time — rebuild to pick up
new CKAN datasets). For always-live data, deploy to a Node host and switch to
getServerSidePropsorgetStaticPathsfallback: 'blocking'.
Where to go next
- Core concepts — why the frontend is decoupled from the backend.
/deploy— publish the connected portal.