{"id":49610902,"url":"https://github.com/devchitchat/index97","last_synced_at":"2026-05-04T17:02:01.193Z","repository":{"id":351792249,"uuid":"1208106136","full_name":"devchitchat/index97","owner":"devchitchat","description":"A Bun-native web framework that trusts the platform. File-based routing, zero build steps, HTML that works, JavaScript that ships.","archived":false,"fork":false,"pushed_at":"2026-04-16T15:07:00.000Z","size":2072,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-16T15:12:58.574Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devchitchat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-11T20:34:15.000Z","updated_at":"2026-04-16T15:07:08.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/devchitchat/index97","commit_stats":null,"previous_names":["devchitchat/index97"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/devchitchat/index97","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devchitchat%2Findex97","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devchitchat%2Findex97/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devchitchat%2Findex97/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devchitchat%2Findex97/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devchitchat","download_url":"https://codeload.github.com/devchitchat/index97/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devchitchat%2Findex97/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32616270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-04T17:01:09.990Z","updated_at":"2026-05-04T17:02:01.184Z","avatar_url":"https://github.com/devchitchat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# index97\n\nA Bun-native web framework. File-based routing, server-side templates, zero config.\n\n---\n\n## Prerequisites\n\nInstall [Bun](https://bun.sh):\n\n```bash\ncurl -fsSL https://bun.sh/install | bash\n```\n\n---\n\n## Phase 1 — Up and running in 5 minutes\n\n**1. Create a project**\n\n```bash\nmkdir my-site \u0026\u0026 cd my-site\nbun init -y\nbun add @devchitchat/index97\n```\n\n**2. Create the entry point**\n\n```js\n// server.js\nimport { createServer } from '@devchitchat/index97'\ncreateServer({ pagesDir: './pages' })\n```\n\n**3. Create your first page and layout**\n\n```bash\nmkdir pages pages/public\n```\n\n```html\n\u003c!-- pages/_layout.html --\u003e\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n  \u003ctitle\u003e{{slot:title || My Site}}\u003c/title\u003e\n  \u003clink rel=\"stylesheet\" href=\"/style.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cnav\u003e\n    \u003ca href=\"/\"\u003eHome\u003c/a\u003e\n    \u003ca href=\"/about\"\u003eAbout\u003c/a\u003e\n  \u003c/nav\u003e\n  \u003cmain\u003e\n    {{content}}\n  \u003c/main\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n```html\n\u003c!-- pages/index.html --\u003e\n\u003ctemplate data-slot=\"title\"\u003eHome — My Site\u003c/template\u003e\n\n\u003ch1\u003eHello, world.\u003c/h1\u003e\n\u003cinclude src=\"_greeting.phtml\"\u003e\n```\n\n```html\n\u003c!-- pages/_greeting.phtml --\u003e\n\u003cp\u003eWelcome to index97. Files are routes. No config needed.\u003c/p\u003e\n```\n\n```css\n/* pages/public/style.css */\nbody { font-family: system-ui, sans-serif; max-width: 800px; margin: 2rem auto; padding: 0 1rem; }\nnav a { margin-right: 1rem; }\n```\n\n**4. Run it**\n\n```bash\nbun server.js\n```\n\nOpen [http://localhost:3000](http://localhost:3000). Edit any file — the browser updates instantly.\n\n---\n\n## Phase 2 — Level up\n\n### Dynamic routes\n\nWrap a folder name in brackets to make it a parameter.\n\n```\npages/\n  blog/\n    [slug].js       ← handles /blog/hello-world\n    [slug].phtml    ← template for the above\n```\n\n```js\n// pages/blog/[slug].js\nimport db from './_db.js'\n\nexport async function GET(req) {\n  const post = db.query('SELECT * FROM posts WHERE slug = ?').get(req.params.slug)\n  if (!post) return new Response('', { status: 404 })\n  return { post }\n}\n```\n\n```html\n\u003c!-- pages/blog/[slug].phtml --\u003e\n\u003ch1\u003e{{post.title}}\u003c/h1\u003e\n\u003cp\u003e{{post.body}}\u003c/p\u003e\n```\n\n### Templates\n\n| Syntax | What it does |\n|--------|-------------|\n| `{{name}}` | Render value, HTML-escaped |\n| `{{{name}}}` | Render value, raw HTML |\n| `{{#if name}}...{{/if}}` | Conditional |\n| `{{#each items}}...{{/each}}` | Loop — `{{this}}` is each item |\n| `\u003cinclude src=\"partial.phtml\"\u003e` | Server-side partial |\n| `\u003cinclude src=\"partial.phtml\" label=\"@item.label\"\u003e` | Pass data to partial |\n\n### Layout slots\n\nPages can inject into named slots in the layout:\n\n```html\n\u003c!-- in any page --\u003e\n\u003ctemplate data-slot=\"title\"\u003eAbout — My Site\u003c/template\u003e\n\u003ctemplate data-slot=\"head\"\u003e\n  \u003clink rel=\"stylesheet\" href=\"/about.css\"\u003e\n\u003c/template\u003e\n\n\u003ch1\u003eAbout\u003c/h1\u003e\n```\n\n```html\n\u003c!-- in _layout.html --\u003e\n\u003ctitle\u003e{{slot:title || My Site}}\u003c/title\u003e\n{{slot:head}}\n{{content}}\n```\n\n### Server-side layout data\n\nExport a `data` function from `_layout.js` to make values available across every page — useful for navigation, session state, feature flags:\n\n```js\n// pages/_layout.js\nexport function data(req) {\n  const session = getSession(req)\n  return { session }\n}\n```\n\n```html\n\u003c!-- in _layout.html --\u003e\n{{#if session}}\u003ca href=\"/signout\"\u003eSign out\u003c/a\u003e{{/if}}\n```\n\n### Forms with PUT / PATCH / DELETE\n\nForms only support GET and POST natively. index97 rewrites the others automatically:\n\n```html\n\u003cform method=\"DELETE\" action=\"/posts/42\"\u003e\n  \u003cbutton\u003eDelete\u003c/button\u003e\n\u003c/form\u003e\n```\n\nExport the matching method from your handler:\n\n```js\nexport async function DELETE(req) {\n  db.run('DELETE FROM posts WHERE id = ?', [req.params.id])\n  return Response.redirect('/posts', 303)\n}\n```\n\n### Static site generation\n\nExport `staticPaths()` from any dynamic handler to tell the build which URLs to render:\n\n```js\n// pages/blog/[slug].js\nexport function staticPaths() {\n  return db.query('SELECT slug FROM posts').all().map(p =\u003e ({ slug: p.slug }))\n}\n```\n\n```bash\nbunx index97 build   # renders all routes to dist/\nbunx index97 serve   # serves dist/ as a static site\n```\n\n---\n\n## CLI\n\n| Command | What it does |\n|---------|-------------|\n| `bunx index97` | Start dev server with HMR |\n| `bunx index97 start` | Start production server |\n| `bunx index97 build` | Generate static site to `dist/` |\n| `bunx index97 serve` | Serve a pre-built `dist/` |\n\n## Project layout\n\n```\nmy-site/\n  server.js           ← entry point\n  pages/\n    _layout.html      ← wraps every page\n    _layout.js        ← server-side data for the layout\n    index.html        ← /\n    about.html        ← /about\n    blog/\n      index.html      ← /blog\n      [slug].js       ← /blog/:slug  (handler)\n      [slug].phtml    ← template for the handler\n    public/\n      style.css       ← served as static files\n      logo.png\n```\n\nFiles starting with `_` are private — they are not routes.\n\n---\n\n## Security\n\n### Content Security Policy\n\nindex97 sets the following CSP header on every response by default:\n\n```\ndefault-src 'self'; style-src 'self'; script-src 'self'\n```\n\nThis means **inline styles and inline scripts are blocked**. Use external stylesheets and script files served from `pages/public/` instead.\n\n```html\n\u003c!-- blocked --\u003e\n\u003cdiv style=\"color: red\"\u003ehello\u003c/div\u003e\n\u003cstyle\u003ebody { margin: 0 }\u003c/style\u003e\n\n\u003c!-- allowed --\u003e\n\u003clink rel=\"stylesheet\" href=\"/style.css\"\u003e\n```\n\nTo override the CSP, pass a `csp` option to `createServer`:\n\n```js\nimport { createServer } from '@devchitchat/index97'\ncreateServer({\n  pagesDir: './pages',\n  csp: \"default-src 'self'; style-src 'self' 'unsafe-inline'\"\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevchitchat%2Findex97","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevchitchat%2Findex97","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevchitchat%2Findex97/lists"}