npm package: @splunk/create
Description: Generate Splunk UI app and component projects
Author: Splunk Inc.
Latest version: 10.4.0

# @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](../react-ui/), [@splunk/dashboard-core](../dashboard-docs/), and [@splunk/visualizations](../visualizations/).

What will you create? Check out our [Examples Gallery](../../toolkits/suit/examplesgallery) for inspiration.

> **Standalone mode:** If you want to create a standalone React app with Splunk UI tooling (without the Splunk app
> monorepo), use `npx @splunk/create --mode=standalone`. See the [Standalone App](/StandaloneApp) guide for details.

### 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](https://www.splunk.com/en_us/download/splunk-enterprise.html).

### Setting up $SPLUNK_HOME
```bash
# 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:$PATH
```

## Getting started
To generate files for a Splunk app, run `npx @splunk/create` from an empty project folder.
```bash
$ 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 Page
```

Next, install project dependencies:
```bash
$ yarn setup
```

You’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:

```bash
# 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 start
```
This 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](https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/assetcaching/) (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.

```bash
# navigate to the page directory
$ cd packages/my-page

# start the local development demo
$ yarn run start:demo
```

Go 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](/TodoList)
* Learn about the dev tools available in your new project -> [Dev Tools](/DevTools)
* Learn more about how your Splunk app is set up -> [Generated Splunk app code](/GeneratedCode)
* Learn how to package your Splunk app -> [Packaging a @splunk/create app](/PackagingYourApp)
* Check out examples for inspiration ->  [Examples Gallery](../../toolkits/suit/examplesgallery)