An open API service indexing awesome lists of open source software.

https://github.com/uiwjs/react-stackblitz

A React component is provided that allows you to programmatically generate stackblitz projects from code samples on the fly.
https://github.com/uiwjs/react-stackblitz

react react-component stackblitz

Last synced: about 15 hours ago
JSON representation

A React component is provided that allows you to programmatically generate stackblitz projects from code samples on the fly.

Awesome Lists containing this project

README

        

React StackBlitz
===

[![Build & Deploy](https://github.com/uiwjs/react-stackblitz/actions/workflows/ci.yml/badge.svg)](https://github.com/uiwjs/react-stackblitz/actions/workflows/ci.yml)
[![Issues](https://img.shields.io/github/issues/uiwjs/react-stackblitz.svg)](https://github.com/uiwjs/react-stackblitz/issues)
[![Forks](https://img.shields.io/github/forks/uiwjs/react-stackblitz.svg)](https://github.com/uiwjs/react-stackblitz/network)
[![Stars](https://img.shields.io/github/stars/uiwjs/react-stackblitz.svg)](https://github.com/uiwjs/react-stackblitz/stargazers)
[![Release](https://img.shields.io/github/release/uiwjs/react-stackblitz)](https://github.com/uiwjs/react-stackblitz/releases)
[![npm version](https://img.shields.io/npm/v/@uiw/react-stackblitz.svg)](https://www.npmjs.com/package/@uiw/react-stackblitz)

A React component is provided that allows you to programmatically generate [stackblitz](https://stackblitz.com/) projects from code samples on the fly.

## Install

```bash
npm install @uiw/react-stackblitz --save
```

## Usage

```jsx
import React from 'react';
import StackBlitz from '@uiw/react-stackblitz';

const code = `import React from "react";
import ReactDOM from "react-dom";
import Avatar from '@uiw/react-avatar';
import "@uiw/react-avatar/lib/esm/style/index.css";

ReactDOM.render(












,
document.getElementById("root")
);`;

const Example = () => {
return (
`,
"index.js": code,
}}
>
Basic Example Open in StackBlitz

)
}
```

## Props

```typescript
type StackBlitzProps = Project & React.ButtonHTMLAttributes & {
/**
* String of the Github username, repo and optionally branch/tag/commit.
* https://developer.stackblitz.com/docs/platform/javascript-sdk#sdkopengithubprojectreposlug-opts
*/
repoSlug?: string;
projectId?: string;
embedOpts?: EmbedOpts;
openOpts?: OpenOptions;
};
```

## Development

Runs the project in development mode.

```bash
# Step 1, run first, listen to the component compile and output the .js file
# listen for compilation output type .d.ts file
npm run watch
# Step 2, development mode, listen to compile preview website instance
npm run start
```

**production**

Builds the app for production to the build folder.

```bash
npm run build
```

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

### Related

- [`@uiw/react-codepen`](https://github.com/uiwjs/react-codepen)
- [`@uiw/react-codesandbox`](https://github.com/uiwjs/react-codesandbox)

## Contributors

As always, thanks to our amazing contributors!



Made with [github-action-contributors](https://github.com/jaywcjlove/github-action-contributors).

## License

Licensed under the MIT License.