Changeset View
Changeset View
Standalone View
Standalone View
modules/docs/chronik.e.cash/docs/1-chronik-js/01-connect.mdx
- This file was added.
--- | |||||
sidebar_position: 2 | |||||
--- | |||||
# Connect | |||||
Connect to a Chronik node via `chronik-client`. | |||||
Import `ChronikClientNode` (soon to become `ChronikClient`) and provide it the Chronik URL in the constructor: | |||||
```tsx | |||||
import { ChronikClientNode } from 'chronik-client'; | |||||
const chronik = new ChronikClientNode('https://chronik-native1.fabien.cash'); | |||||
``` | |||||
## Try it out! | |||||
You can try it out in this React component: | |||||
```jsx live | |||||
function DemoConnect() { | |||||
return ( | |||||
<Json | |||||
fn={async () => { | |||||
const chronik = new ChronikClientNode( | |||||
'https://chronik-native1.fabien.cash', | |||||
); | |||||
return await chronik.blockchainInfo(); | |||||
}} | |||||
/> | |||||
); | |||||
} | |||||
``` |