- Summary
- Overview
- Project scope
- What's included?
- Prerequisites
- Getting started
- Project structure
- Usage
- Customization
- Building for production
- Deploying your application
- Troubleshooting
- Contributing
- License
- Acknowledgements
If you're searching for a way to take the small web applications Claude generates with its Artifacts feature, and run them outside of its website, you've come to the right place.
This project provides a standalone environment that mimics the Artifacts runtime, enabling you to run, test, and further develop the code generated by Claude independently from its website.
If you've created a web application or component using Claude's Artifacts feature and want to:
- run the component locally for testing and development,
- use the component as a starting point for a new project or integrate it into a larger project, or
- deploy the component as a standalone application,
you'll be disappointed to find out that, if you download the artifact code via the download button, you'll only receive a single file containing the main logic of the app, not the full project with all necessary files to run it on your computer.
If you're unfamiliar with the technologies used on the project, you'll have a hard time assembling and configuring all the required libraries and tooling required to make a running standalone app.
Even if you're an experienced developer, you may just want to save time and effort and get the Artifact running as easily and as soon as possible.
This scaffold/boilerplate provides the fastest and easiest way to get your artifact up and running on your machine. It includes all the necessary dependencies and configurations to seamlessly transition your Claude-generated artifact into a fully functional web application in no time.
This project is meant only for running Artifacts that are interactive web apps, usually made in React, and for which Claude writes Javascript or Typescript code.
Mermaid diagrams, SVGs, and other document-type Artifacts are out of the project’s scope.
Why? Well, because those types of simple static content are easily viewable by other means.
For example, to view Mermaid diagrams, you can use an online viewer/editor, like mermaidflow.app, from which you can also export the diagram to SVG or PNG.
These are the libraries and frameworks this project provides, identical to those available on Claude's Artifacts environment:
- React 18 for building user interfaces.
- TypeScript to support artifacts written in type-safe Javascript.
- Vite for fast development and building.
- Shadcn UI for pre-built, customizable components.
- Tailwind CSS for compact and expressive embedded styling.
- Recharts for creating dynamic, customizable charts and data visualizations.
- Lucide React for a comprehensive library of open-source icons designed for React applications.
Note that the actual versions of the packages currently in use in the Artifacts environment may differ from the ones installed by this project, as Anthropic may update them from time to time.
If a component generated by Claude fails to run properly because of an outdated package, please let me know.
Before you begin, ensure you have the following installed:
- Node.js minimum supported version is 16 (lts/gallium), tested up to version 23.2
- npm (usually comes with Node.js)
-
Clone the repository:
git clone https://github.com/claudio-silva/claude-artifact-runner.git cd claude-artifact-runner
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser and visit
http://localhost:5173
to see the default app running.
src/
: Contains the source code for the applicationApp.tsx
: Main application componentartifact-component.tsx
: Place to paste the component generated by Claudecomponents/
: Reusable UI componentslib/
: Utility functions and helpers
public/
: Static assetsindex.html
: Entry HTML filevite.config.ts
: Vite configurationtsconfig.json
: TypeScript configurationtailwind.config.js
: Tailwind CSS configurationpackage.json
: all the required packages are registered here.
- Generate a React component using Claude on the Artifacts environment.
- Copy the generated component code.
- Paste the code into
src/artifact-component.tsx
, completely replacing the file contents. - If you have
npm run dev
running, the page should refresh automatically to display the new component.
- Use
src/index.css
to add additional CSS rules. - Place static assets (such as images) in the
public
folder. - Modify
tailwind.config.js
to customize the Tailwind CSS theme. - Update
App.tsx
to change the overall layout or add new features. - Add or modify components in the
src/components/
directory.Note: Shadcn UI components installed via
npx
are automatically placed insrc/components
. All components come pre-installed by default, but if you remove some and later want to reinstall any, you may simply runnpx shadcn-ui@latest add <your-component>
.
The Recharts library and ALL Shadcn UI components come pre-installed, so that all code that Claude may generate will run out-of-the-box.
If you just want to run the artifact locally, you may leave things as they are, but if you want to deploy the application or use it as a base for a larger project, you may want to optimize the application's bundle size.
To do that, you may remove the pre-installed components or libraries that are not required by your application.
Just delete the component's folder from src/components
.
Use npm remove
to uninstall them.
To create a production build, run:
npm run build
This will generate optimized files in the dist/
directory, ready for deployment.
After running npm run build
, you'll have a dist
folder containing the built files (typically an HTML file, a JavaScript file, and a CSS file).
Here are several ways to deploy these files:
For local testing of the production build, you can use the serve
package:
-
Install
serve
globally:npm install -g serve
-
Navigate to your project directory and run:
serve -s dist
-
Open a browser and go to
http://localhost:3000
(or the URL provided in the terminal).
If you want to deploy to a shared or dedicated web server:
- Upload the contents of the
dist
folder to your web server's public HTML directory (often calledpublic_html
,www
, orhtdocs
).
Remember to update any necessary configuration files (like vite.config.ts
) before building your app if it is not being served from the root of your domain.
For example, for vite.config.ts
, you may configure it like this:
export default {
base: '/subdirectory/', // Set this to the path your app is served from
// other configurations
};
Here are some popular free cloud hosting platforms and how to deploy your app to them:
Remember to run
npm run build
before deploying to ensure you're uploading the latest version of your app.
-
Install the Netlify CLI:
npm install -g netlify-cli
-
Run the following command in your project directory:
netlify deploy
-
Follow the prompts. When asked for the publish directory, enter
dist
. -
For production deployment, use:
netlify deploy --prod
-
Install the Vercel CLI:
npm install -g vercel
-
Run the following command in your project directory:
vercel
-
Follow the prompts. Vercel will automatically detect that it's a Vite project and use the correct settings.
-
If you haven't already, create a GitHub repository for your project.
-
Install the
gh-pages
package:npm install gh-pages --save-dev
-
Add these scripts to your
package.json
:"scripts": { "predeploy": "npm run build", "deploy": "gh-pages -d dist" }
-
Run:
npm run deploy
-
Set up GitHub Pages in your repository settings to use the
gh-pages
branch.
You can deploy to Cloudflare Pages either through the Cloudflare dashboard or using the wrangler
CLI tool. Here's how to do it using wrangler
, which is often the most straightforward method:
-
Install Wrangler:
npm install -g wrangler
-
Login to Cloudflare:
wrangler login
-
Deploy your project:
wrangler pages deploy dist
This command will prompt you to create a new project if one doesn't exist, and then deploy your
dist
folder to Cloudflare Pages. -
Configure your project (optional): If you need more control over your deployment, you can create a
wrangler.toml
file in your project root:name = "my-react-app" compatibility_date = "2024-07-16" # Replace with the current date [site] bucket = "./dist"
Note: The
account_id
andworkers_dev
fields are typically not needed for Cloudflare Pages deployments. -
Custom domain and production settings: To use a custom domain or configure production settings, you can use the Cloudflare Pages dashboard. There, you can set up your domain, configure environment variables, and manage other deployment settings.
If you encounter any issues, try the following:
- Clear your browser cache and restart the development server.
- Delete the
node_modules
folder and runnpm install
again. - Make sure your Node.js version is compatible with the project requirements.
- Check for any error messages in the console and search for solutions online.
If problems persist, please open an issue on this project's GitHub repository.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
I found Claude-React-Jumpstart when looking for a way to run Artifacts outside of claude.ai.
However, it did not fully meet my needs, so I decided to make my own project, as I wanted something that:
- was completely pre-configured (no need to install or configure additional stuff),
- was ready to go with a single
npm install
, and - included all components and libraries needed to fully replicate the Artifacts environment.