@splunk/create
v10.1.0
Published
Generate Splunk UI app and component projects
Keywords
Readme
@splunk/create
What is @splunk/create?
@splunk/create generates code and scaffolding for a new Splunk application, built with React, via CLI.
By using @splunk/create, you can quickly start developing with Splunk provided packages such as @splunk/react-ui, @splunk/dashboard-core, and @splunk/visualizations.
What will you create? Check out our Examples Gallery for inspiration.
Requirements
- Yarn >= 1.2
- Node >= 22
Prerequisites
To run your Splunk app locally you will need a local Splunk Enterprise instance with $SPLUNK_HOME set.
For more information on getting a local instance, see the Splunk Enterprise downloads page.
Setting up $SPLUNK_HOME
# Set SPLUNK_HOME to point to the top-level installation directory
$ export SPLUNK_HOME=/opt/splunk
# Add $SPLUNK_HOME/bin to the shell’s path.
$ export PATH=$SPLUNK_HOME/bin:$PATHGetting started
To generate files for a Splunk app, run npx @splunk/create from an empty project folder.
$ mkdir project-folder
$ cd project-folder
$ npx @splunk/create
#? What do you want to name your Splunk app?: MySplunkApp
#? What do you want to name your new page?: MyPage
#? What type of page would you like to create?: Add a Basic PageNext, install project dependencies:
$ yarn setupYou’ll now have two main directories, one for the created React page and one for the created Splunk app.
- packages/my-page
- packages/my-splunk-app
Splunk demo
Splunk demo will allow you to view your new app inside your local Splunk instance:
# navigate to your app folder
$ cd packages/my-splunk-app
# link the app to your local Splunk instance
$ yarn link:app
# check that the link is set (optional)
$ ls -l $SPLUNK_HOME/etc/apps/my-splunk-app
# restart Splunk (will start Splunk if not already started)
$ splunk restart
# navigate to the root project directory
$ cd ../../
# start the Splunk app
$ yarn startThis will watch both your my-splunk-app and my-page folders for changes and rebundle.
You should now see your app in the left hand menu of the Splunk Enterprise home page, typically located at https://localhost:8000.
There is no hot-reloading within Splunk, you'll need to manually refresh the page to see changes.
If you are not seeing your changes you can try:
- hard reloading Shift+Command+R (Ctrl+Shift+R on Windows) in Google Chrome
- disabling Splunk asset cache (not recommended for production environments)
- using https://localhost:8000/en-US/_bump
Local React demo
Sometimes developing within Splunk is not the most efficient, which is why we also provide a local development environment specifically for your React page.
# navigate to the page directory
$ cd packages/my-page
# start the local development demo
$ yarn run start:demoGo to http://localhost:8080/ to see your new React page in action.
Page files are located in packages/my-page/src. Make a change to a file to see it update in the demo.
What’s next
- Check out our tutorials -> Tutorial: Creating a todo list
- Learn about the dev tools available in your new project -> Dev Tools
- Learn more about how your Splunk app is set up -> Generated Splunk app code
- Learn how to package your Splunk app -> Packaging a @splunk/create app
- Check out examples for inspiration -> Examples Gallery
