codesandbox / sandpack

A component toolkit for creating live-running code editing experiences, using the power of CodeSandbox.
https://sandpack.codesandbox.io
Apache License 2.0
4.92k stars 351 forks source link

Sandpack Provider without using a template #985

Open jamesmurdza opened 1 year ago

jamesmurdza commented 1 year ago

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? ```js import './App.css' import { SandpackProvider, SandpackLayout, SandpackPreview, SandpackConsole } from "@codesandbox/sandpack-react"; export default function App() { const files = {} return ( ) } ```
husniramdani commented 2 months ago

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>