sandpack
sandpack copied to clipboard
Sandpack Provider without using a template
Discussed in https://github.com/codesandbox/sandpack/discussions/970
Originally posted by jamesmurdza July 15, 2023
If I remove, template="static" from the below code, the template is still applied. I want to provide my own directory structure with a completely different list of files. How can I do this?
import './App.css'
import { SandpackProvider, SandpackLayout, SandpackPreview, SandpackConsole } from "@codesandbox/sandpack-react";
export default function App() {
const files = {}
return (
<SandpackProvider
files={files}
theme="light"
template="static"
>
<SandpackLayout>
<SandpackPreview />
<SandpackConsole />
</SandpackLayout>
</SandpackProvider>
)
}
```</div>
Try this
<SandpackProvider
theme="auto"
files={{
'/user.sql': `CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
age INTEGER NOT NULL
);
`,
}}
customSetup={{
entry: '/user.sql',
}}
>
<SandpackLayout>
<SandpackPreview />
<SandpackConsole />
</SandpackLayout>
</SandpackProvider>
Try this
<SandpackProvider theme="auto" files={{ '/user.sql': `CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, age INTEGER NOT NULL ); `, }} customSetup={{ entry: '/user.sql', }} > <SandpackLayout> <SandpackPreview /> <SandpackConsole /> </SandpackLayout> </SandpackProvider>
with "@codesandbox/sandpack-react": "^2.20.0", a package.json is still involved: