You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: review local-first development
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
* feat: more local development
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
---------
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
Copy file name to clipboardExpand all lines: docs/build/functions/lifecycle.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Once your project is scaffolded, proceed to define Rust functions and annotate t
18
18
19
19
### Local Development
20
20
21
-
For local development and testing, a sandbox environment is essential. With Docker installed and using the CLI, you can establish this environment by running `juno dev start`. Alternatively, manual setup instructions are available in the [documentation](../../guides/local-development.md) for a more customized approach.
21
+
For local development and testing, a sandbox environment is essential. With Docker installed and using the CLI, you can establish this environment by running `juno dev start`. Alternatively, manual setup instructions are available in the [documentation](../../guides/local-development.mdx) for a more customized approach.
Copy file name to clipboardExpand all lines: docs/guides/local-development.mdx
+35-67Lines changed: 35 additions & 67 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,11 @@ sidebar_position: 11
7
7
8
8
# Local Development
9
9
10
-
When you get started with Juno, you are using your smart contract deployed on the blockchain in production. If you are interested in developing or testing your apps in continuous integration workflows, this guide will show you how you can run a Satellite in a Docker sandbox.
10
+
The tooling is designed with local-first development in mind. Whether you're using the official [plugins](../reference/plugins.md) (Next.js, Vite) or creating a new project with `npm create juno@latest`, local development is the default experience.
11
+
12
+
When running `npm run dev` (or `start`), your app connects to a locally simulated Satellite via the provided emulator — so you can build and test your backend logic without deploying to the live network.
13
+
14
+
For continuous integration workflows or advanced setups, this guide shows how to run a Docker-based sandbox that closely mirrors the production environment.
11
15
12
16
---
13
17
@@ -25,61 +29,29 @@ For MacBooks with M processors, it is important to use Docker Desktop version 4.
25
29
26
30
## Getting Started
27
31
28
-
There are two ways to start a local developer environment:
29
-
30
-
### Automated
32
+
The easiest way to run the local developer environment is through the CLI.
31
33
32
-
If you've installed Juno's CLI on your machine, you can start a local container by simply running the `juno dev start` command in your terminal.
34
+
If you haven’t installed it yet, run:
33
35
34
-
The first time you execute this command, it will prompt you to automatically populate the required configuration.
36
+
importClifrom"./components/cli.mdx";
35
37
36
-
To start the container, run this command whenever needed. Use `juno dev stop` to halt the container.
38
+
<Cli />
37
39
38
-
### Manually
40
+
Then, in your project folder, start the local emulator with:
In addition, create a file named `juno.dev.config.json` next to your Docker Compose file and populate it with the required fields.
46
+
This will launch a local Satellite along with a local Internet Identity, allowing you to develop and test without deploying anything live.
59
47
60
-
```json title="juno.dev.config.json"
61
-
{
62
-
"satellite": {
63
-
"collections": {}
64
-
}
65
-
}
66
-
```
48
+
We recommend running this in a dedicated terminal window or tab, while your frontend project (e.g. using Vite or Next.js) runs separately using npm run dev or similar.
67
49
68
-
Once the configuration is set, start the container using the following Docker command:
50
+
To stop the emulator, run:
69
51
52
+
```bash
53
+
juno dev stop
70
54
```
71
-
docker compose up
72
-
```
73
-
74
-
That's all it takes to run the local environment. At this point, you should have a container that exposes a Satellite and an Internet Identity for local development or end-to-end testing purposes.
75
-
76
-
:::note
77
-
78
-
You can run or compose the Juno Docker image from your terminal. This guide explains the latter.
79
-
80
-
It's worth noting that you can run multiple containers simultaneously, as long as they operate on different ports. Additionally, you can apply various configurations for different projects.
81
-
82
-
:::
83
55
84
56
---
85
57
@@ -247,39 +219,35 @@ volumes:
247
219
248
220
## Usage
249
221
250
-
When integrating your application with the container during Juno initialization, you have two primary options. The first is to set a specific parameter to `true`, which applies the default container configuration. The second option is to provide a custom `string` as the URL of the container, which is especially beneficial if you're using a custom port.
251
-
252
-
### Plugins
222
+
During local development, your app connects to the local emulator (container) by default — no extra configuration needed.
253
223
254
-
If you are utilizing the [Vite](../reference/plugins.md#vite-plugin) or [NextJS](../reference/plugins.md#nextjs-plugin), you can configure the container directly within the plugin settings:
224
+
This is handled automatically when using the [plugins](../reference/plugins.md), or when starting from a template.
255
225
256
-
```javascript title="vite.config.js"
257
-
import juno from "@junobuild/vite-plugin";
258
-
259
-
export default defineConfig({
260
-
plugins: [
261
-
juno({
262
-
container: true
263
-
})
264
-
]
265
-
});
266
-
```
267
-
268
-
The plugin will automatically load the necessary environment variables for the container configuration so that your app uses it when you develop.
226
+
If needed, you can opt out of the container behavior by explicitly setting `container: false`.
269
227
270
228
### Manual Initialization
271
229
272
-
If you are not using the plugins, you should set the satellite ID to the static ID used in the container, which is `jx5yt-yyaaa-aaaal-abzbq-cai`. The initialization would look like this:
230
+
If you're not using a plugin and are initializing Juno manually, here's how to configure it to use the local container:
273
231
274
-
```typescript
232
+
```javascript
275
233
import { initSatellite } from "@junobuild/core";
276
234
235
+
const container = import.meta.env.DEV === true;
236
+
277
237
await initSatellite({
278
-
// TODO: replace DEV flag according your need and the production satellite ID as well
279
-
satelliteId: DEV
238
+
satelliteId: container
280
239
? "jx5yt-yyaaa-aaaal-abzbq-cai"
281
240
: "aaaaa-bbbbb-ccccc-ddddd-cai",
282
-
container: true
241
+
container
242
+
});
243
+
```
244
+
245
+
The SDK will automatically detect the container in local development. If you want to disable that behavior and connect directly to a remote canister (e.g. in CI or production testing), you can do:
Copy file name to clipboardExpand all lines: docs/intro.mdx
+2-14Lines changed: 2 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,25 +37,13 @@ import { Bash } from "./components/bash.mdx";
37
37
38
38
...and follow the prompts.
39
39
40
-
:::note
41
-
42
-
Our CLI tool is compatible with Mac, Linux, and Windows and requires [NodeJS](https://nodejs.org/en) to be installed. It also supports Yarn and pnpm.
43
-
44
-
:::
45
-
46
40
---
47
41
48
42
## Local development
49
43
50
-
Want to develop locally before going live? Or just want to test out Juno in a non-production environment?
51
-
52
-
Use our [local development emulator](./guides/local-development.md) to build and test your projects in an environment that closely mirrors production, without needing to deploy live.
53
-
54
-
:::tip
55
-
56
-
The emulator comes with all starter templates. Just run `npm create juno@latest` to begin.
44
+
Juno's tooling is designed for local-first development. Whether you're using the Next.js or Vite [plugins](reference/plugins.md), or creating a new app with `npm create juno@latest`, your project runs locally by default.
57
45
58
-
:::
46
+
With the provided [emulator](./guides/local-development.md), you can build and test your projects in an environment that closely mirrors production, without the need to deploy live until you're ready.
0 commit comments