Local Development for Space
March 23, 2023
Since the introduction of Deta Space, developers have been asking for a better experience when building locally for Space. Whether it is managing keys or coordinating between two separate Micros, local development requires unnecessary work.
We are happy to announce that the newest Space CLI can now do a lot of the heavy lifting, with a single command:
If you’ve got a Space project you want to run locally, just run the following command, from the root of your project:
Et voila! Your app is now running locally and you can access it at
http://localhost:4200 (the Space CLI will tell you this).
You can also add the
--open flag to open the app in your browser automatically.
Behind the scenes, the Space CLI is:
- Generating and injecting a Data Key to allow your app to write data to your project
- Running each of your Micros in a separate process (using a new
devcommand from your Spacefile)
- Exposing all of your Micros through a single entrypoint (following the routing in your Spacefile)
For more information on how setup and use the command, make sure to check out the docs.
If your Spacefile contains a Scheduled Action, you can also now trigger it locally for testing.
For example, if you have the following Spacefile:
After starting the app locally with
space dev, you can now trigger the
cleanup action by running the following command:
Behind the scenes, the Space CLI will:
- Send the action event to your Micro locally
- Print the returned response to your console (if any)
space exec commands allows you to give a local command or script access to your project’s Deta Base and Drive data. It does so by creating and injecting a Data Key as
DETA_PROJECT_KEY into your local environment.
Some use cases include:
- testing Base & Drive locally
- pre-filling your projects Bases & Drives with data
- programmatically interacting with Base & Drive
- … anything else you can think of!
To use all the new commands, make sure to upgrade to the latest version of the Space CLI, with the following command:
That’s all for now. Thank you for all the feedback — please continue to share!