Repository: denoland/fresh
Branch: main
Commit: 4cc76aefed73
Files: 485
Total size: 1.3 MB
Directory structure:
gitextract__i6wh6to/
├── .gitattributes
├── .github/
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── dependabot.yml
│ └── workflows/
│ ├── ci.yml
│ ├── deploy.yml
│ ├── post_publish.yml
│ └── publish.yml
├── .gitignore
├── .vscode/
│ ├── extensions.json
│ ├── settings.json
│ └── tailwind.json
├── LICENSE
├── README.md
├── _typos.toml
├── deno.json
├── docs/
│ ├── 1.x/
│ │ ├── concepts/
│ │ │ ├── ahead-of-time-builds.md
│ │ │ ├── app-wrapper.md
│ │ │ ├── architecture.md
│ │ │ ├── data-fetching.md
│ │ │ ├── deployment.md
│ │ │ ├── error-pages.md
│ │ │ ├── forms.md
│ │ │ ├── index.md
│ │ │ ├── islands.md
│ │ │ ├── layouts.md
│ │ │ ├── middleware.md
│ │ │ ├── partials.md
│ │ │ ├── plugins.md
│ │ │ ├── routes.md
│ │ │ ├── routing.md
│ │ │ ├── server-components.md
│ │ │ ├── server-configuration.md
│ │ │ ├── static-files.md
│ │ │ └── updating.md
│ │ ├── examples/
│ │ │ ├── active-links.md
│ │ │ ├── authentication-with-supabase.md
│ │ │ ├── changing-the-src-dir.md
│ │ │ ├── client-side-components-and-libraries.md
│ │ │ ├── creating-a-crud-api.md
│ │ │ ├── dealing-with-cors.md
│ │ │ ├── handling-complex-routes.md
│ │ │ ├── index.md
│ │ │ ├── init-the-server.md
│ │ │ ├── migrating-to-tailwind.md
│ │ │ ├── modifying-the-head.md
│ │ │ ├── rendering-markdown.md
│ │ │ ├── rendering-raw-html.md
│ │ │ ├── setting-the-language.md
│ │ │ ├── sharing-state-between-islands.md
│ │ │ ├── using-csp.md
│ │ │ ├── using-fresh-canary-version.md
│ │ │ ├── using-twind-v1.md
│ │ │ └── writing-tests.md
│ │ ├── getting-started/
│ │ │ ├── adding-interactivity.md
│ │ │ ├── create-a-project.md
│ │ │ ├── create-a-route.md
│ │ │ ├── custom-handlers.md
│ │ │ ├── deploy-to-production.md
│ │ │ ├── dynamic-routes.md
│ │ │ ├── form-submissions.md
│ │ │ ├── index.md
│ │ │ └── running-locally.md
│ │ ├── integrations/
│ │ │ └── index.md
│ │ └── introduction/
│ │ └── index.md
│ ├── canary/
│ │ └── the-canary-version/
│ │ └── index.md
│ ├── latest/
│ │ ├── advanced/
│ │ │ ├── app-wrapper.md
│ │ │ ├── builder.md
│ │ │ ├── define.md
│ │ │ ├── environment-variables.md
│ │ │ ├── error-handling.md
│ │ │ ├── forms.md
│ │ │ ├── head.md
│ │ │ ├── index.md
│ │ │ ├── layouts.md
│ │ │ ├── partials.md
│ │ │ ├── troubleshooting.md
│ │ │ └── vite.md
│ │ ├── concepts/
│ │ │ ├── app.md
│ │ │ ├── context.md
│ │ │ ├── file-routing.md
│ │ │ ├── index.md
│ │ │ ├── islands.md
│ │ │ ├── layouts.md
│ │ │ ├── middleware.md
│ │ │ ├── routing.md
│ │ │ └── static-files.md
│ │ ├── deployment/
│ │ │ ├── cloudflare-workers.md
│ │ │ ├── deno-compile.md
│ │ │ ├── deno-deploy.md
│ │ │ ├── docker.md
│ │ │ └── index.md
│ │ ├── examples/
│ │ │ ├── active-links.md
│ │ │ ├── daisyui.md
│ │ │ ├── markdown.md
│ │ │ ├── migration-guide.md
│ │ │ ├── rendering-raw-html.md
│ │ │ └── sharing-state-between-islands.md
│ │ ├── getting-started/
│ │ │ └── index.md
│ │ ├── introduction/
│ │ │ └── index.md
│ │ ├── plugins/
│ │ │ ├── cors.md
│ │ │ ├── csp.md
│ │ │ ├── csrf.md
│ │ │ ├── index.md
│ │ │ └── trailing-slashes.md
│ │ └── testing/
│ │ └── index.md
│ └── toc.ts
├── packages/
│ ├── build-id/
│ │ ├── README.md
│ │ ├── deno.json
│ │ └── mod.ts
│ ├── examples/
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── deno.json
│ │ └── src/
│ │ ├── app1.tsx
│ │ ├── app2.tsx
│ │ ├── island.tsx
│ │ └── shared.tsx
│ ├── fresh/
│ │ ├── README.md
│ │ ├── deno.json
│ │ ├── src/
│ │ │ ├── app.ts
│ │ │ ├── app_test.tsx
│ │ │ ├── build_cache.ts
│ │ │ ├── commands.ts
│ │ │ ├── compat.ts
│ │ │ ├── compat_test.tsx
│ │ │ ├── config.ts
│ │ │ ├── config_test.ts
│ │ │ ├── constants.ts
│ │ │ ├── context.ts
│ │ │ ├── context_test.tsx
│ │ │ ├── define.ts
│ │ │ ├── define_test.ts
│ │ │ ├── dev/
│ │ │ │ ├── builder.ts
│ │ │ │ ├── builder_test.ts
│ │ │ │ ├── check.ts
│ │ │ │ ├── dev_build_cache.ts
│ │ │ │ ├── dev_build_cache_test.ts
│ │ │ │ ├── esbuild.ts
│ │ │ │ ├── file_transformer.ts
│ │ │ │ ├── file_transformer_test.ts
│ │ │ │ ├── fs_crawl.ts
│ │ │ │ ├── fs_crawl_test.ts
│ │ │ │ ├── middlewares/
│ │ │ │ │ ├── automatic_workspace_folders.ts
│ │ │ │ │ ├── error_overlay/
│ │ │ │ │ │ ├── code_frame.ts
│ │ │ │ │ │ ├── middleware.tsx
│ │ │ │ │ │ ├── middleware_test.tsx
│ │ │ │ │ │ └── overlay.tsx
│ │ │ │ │ └── live_reload.ts
│ │ │ │ ├── mod.ts
│ │ │ │ ├── update_check.ts
│ │ │ │ └── update_check_test.ts
│ │ │ ├── error.ts
│ │ │ ├── error_test.ts
│ │ │ ├── file_url.ts
│ │ │ ├── file_url_test.ts
│ │ │ ├── fs.ts
│ │ │ ├── fs_routes.ts
│ │ │ ├── fs_routes_test.tsx
│ │ │ ├── handlers.ts
│ │ │ ├── internals.ts
│ │ │ ├── internals_dev.ts
│ │ │ ├── jsonify/
│ │ │ │ ├── __snapshots__/
│ │ │ │ │ └── round_trip_test.ts.snap
│ │ │ │ ├── constants.ts
│ │ │ │ ├── custom_test.ts
│ │ │ │ ├── parse.ts
│ │ │ │ ├── round_trip_test.ts
│ │ │ │ ├── stringify.ts
│ │ │ │ └── stringify_test.ts
│ │ │ ├── middlewares/
│ │ │ │ ├── cors.ts
│ │ │ │ ├── cors_test.ts
│ │ │ │ ├── csp.ts
│ │ │ │ ├── csp_test.ts
│ │ │ │ ├── csrf.ts
│ │ │ │ ├── csrf_test.ts
│ │ │ │ ├── mod.ts
│ │ │ │ ├── mod_test.ts
│ │ │ │ ├── static_files.ts
│ │ │ │ ├── static_files_test.ts
│ │ │ │ ├── trailing_slashes.ts
│ │ │ │ └── trailing_slashes_test.ts
│ │ │ ├── mod.ts
│ │ │ ├── otel.ts
│ │ │ ├── render.ts
│ │ │ ├── router.ts
│ │ │ ├── router_test.ts
│ │ │ ├── runtime/
│ │ │ │ ├── client/
│ │ │ │ │ ├── dev.ts
│ │ │ │ │ ├── mod.ts
│ │ │ │ │ ├── partials.ts
│ │ │ │ │ ├── polyfills.ts
│ │ │ │ │ ├── preact_hooks_client.ts
│ │ │ │ │ └── reviver.ts
│ │ │ │ ├── head.ts
│ │ │ │ ├── server/
│ │ │ │ │ └── preact_hooks.ts
│ │ │ │ ├── shared.ts
│ │ │ │ └── shared_internal.ts
│ │ │ ├── segments.ts
│ │ │ ├── segments_test.ts
│ │ │ ├── server/
│ │ │ │ └── tailwind_aot_error_page.tsx
│ │ │ ├── test_utils.ts
│ │ │ ├── types.ts
│ │ │ ├── utils.ts
│ │ │ └── utils_test.ts
│ │ └── tests/
│ │ ├── active_links_test.tsx
│ │ ├── doc_examples_test.tsx
│ │ ├── fixture_head/
│ │ │ ├── islands/
│ │ │ │ ├── MetaIsland.tsx
│ │ │ │ ├── StyleIdIsland.tsx
│ │ │ │ ├── TemplateIsland.tsx
│ │ │ │ └── TitleIsland.tsx
│ │ │ └── routes/
│ │ │ ├── _app.tsx
│ │ │ ├── id.tsx
│ │ │ ├── key.tsx
│ │ │ ├── meta.tsx
│ │ │ └── title.tsx
│ │ ├── fixture_island_groups/
│ │ │ └── routes/
│ │ │ ├── both/
│ │ │ │ ├── (_islands)/
│ │ │ │ │ └── Foo.tsx
│ │ │ │ └── index.tsx
│ │ │ ├── foo/
│ │ │ │ ├── (_islands)/
│ │ │ │ │ └── Foo.tsx
│ │ │ │ └── index.tsx
│ │ │ └── index.tsx
│ │ ├── fixture_precompile/
│ │ │ ├── invalid/
│ │ │ │ ├── deno.json
│ │ │ │ ├── dev.ts
│ │ │ │ └── main.tsx
│ │ │ └── valid/
│ │ │ ├── deno.json
│ │ │ └── main.tsx
│ │ ├── fixture_update_check/
│ │ │ └── mod.ts
│ │ ├── fixtures_islands/
│ │ │ ├── Computed.tsx
│ │ │ ├── Counter.tsx
│ │ │ ├── CounterWithSlots.tsx
│ │ │ ├── EnvIsland.tsx
│ │ │ ├── EscapeIsland.tsx
│ │ │ ├── FnIsland.tsx
│ │ │ ├── FragmentIsland.tsx
│ │ │ ├── FreshAttrs.tsx
│ │ │ ├── IslandInIsland.tsx
│ │ │ ├── JsonIsland.tsx
│ │ │ ├── JsxChildrenIsland.tsx
│ │ │ ├── JsxConditional.tsx
│ │ │ ├── JsxIsland.tsx
│ │ │ ├── Multiple.tsx
│ │ │ ├── NodeProcess.tsx
│ │ │ ├── NullIsland.tsx
│ │ │ ├── OptOutPartialLink.tsx
│ │ │ ├── PartialInIsland.tsx
│ │ │ ├── PassThrough.tsx
│ │ │ ├── SelfCounter.tsx
│ │ │ └── data.json
│ │ ├── head_test.tsx
│ │ ├── islands_test.tsx
│ │ ├── lorem_ipsum.txt
│ │ ├── partials_test.tsx
│ │ ├── precompile_test.ts
│ │ └── test_utils.tsx
│ ├── init/
│ │ ├── README.md
│ │ ├── deno.json
│ │ └── src/
│ │ ├── init.ts
│ │ ├── init_test.ts
│ │ └── mod.ts
│ ├── plugin-tailwindcss/
│ │ ├── README.md
│ │ ├── deno.json
│ │ └── src/
│ │ ├── mod.ts
│ │ └── types.ts
│ ├── plugin-tailwindcss-v3/
│ │ ├── README.md
│ │ ├── deno.json
│ │ └── src/
│ │ └── mod.ts
│ ├── plugin-vite/
│ │ ├── README.md
│ │ ├── demo/
│ │ │ ├── assets/
│ │ │ │ └── style.css
│ │ │ ├── client.ts
│ │ │ ├── components/
│ │ │ │ ├── CssModuleNonIsland.tsx
│ │ │ │ └── CssModulesNonIsland.module.css
│ │ │ ├── fixtures/
│ │ │ │ ├── commonjs_mod.cjs
│ │ │ │ └── maxmind.cjs
│ │ │ ├── islands/
│ │ │ │ ├── Bar.tsx
│ │ │ │ ├── CssModules.module.css
│ │ │ │ ├── CssModules.tsx
│ │ │ │ ├── CssModulesOther.module.css
│ │ │ │ ├── CssModulesOther.tsx
│ │ │ │ ├── Foo.tsx
│ │ │ │ ├── IslandNestedInner.tsx
│ │ │ │ ├── IslandNestedOuter.tsx
│ │ │ │ └── tests/
│ │ │ │ ├── CounterHooks.tsx
│ │ │ │ ├── EnvIsland.tsx
│ │ │ │ ├── IslandAssets.tsx
│ │ │ │ ├── Mime.tsx
│ │ │ │ └── Ready.tsx
│ │ │ ├── main.ts
│ │ │ ├── routes/
│ │ │ │ ├── _error.tsx
│ │ │ │ ├── about.tsx
│ │ │ │ ├── index.tsx
│ │ │ │ └── tests/
│ │ │ │ ├── CssRoute.module.css
│ │ │ │ ├── api/
│ │ │ │ │ └── [id].tsx
│ │ │ │ ├── assets.tsx
│ │ │ │ ├── build_id.tsx
│ │ │ │ ├── commonjs.tsx
│ │ │ │ ├── css.tsx
│ │ │ │ ├── css_modules.tsx
│ │ │ │ ├── css_styles.css
│ │ │ │ ├── dep_json.tsx
│ │ │ │ ├── env.tsx
│ │ │ │ ├── env_files.tsx
│ │ │ │ ├── feed.tsx
│ │ │ │ ├── ioredis.tsx
│ │ │ │ ├── island_assets.tsx
│ │ │ │ ├── island_hooks.tsx
│ │ │ │ ├── island_nested.tsx
│ │ │ │ ├── it_works.tsx
│ │ │ │ ├── jsx_namespace.tsx
│ │ │ │ ├── maxmind.tsx
│ │ │ │ ├── middlewares/
│ │ │ │ │ ├── _middleware.ts
│ │ │ │ │ └── index.tsx
│ │ │ │ ├── mime.tsx
│ │ │ │ ├── partial.tsx
│ │ │ │ ├── partial_insert.tsx
│ │ │ │ ├── pg.tsx
│ │ │ │ ├── qs.tsx
│ │ │ │ ├── radix.tsx
│ │ │ │ ├── redis.tsx
│ │ │ │ ├── remote_island.tsx
│ │ │ │ ├── stripe.tsx
│ │ │ │ ├── supabase_pg.tsx
│ │ │ │ ├── tailwind.tsx
│ │ │ │ └── throw.tsx
│ │ │ ├── static/
│ │ │ │ ├── foo.txt
│ │ │ │ └── test_static/
│ │ │ │ ├── foo/
│ │ │ │ │ └── index.html
│ │ │ │ └── foo.txt
│ │ │ ├── utils.ts
│ │ │ └── vite.config.ts
│ │ ├── deno.json
│ │ ├── src/
│ │ │ ├── client.ts
│ │ │ ├── mod.ts
│ │ │ ├── plugins/
│ │ │ │ ├── build_id.ts
│ │ │ │ ├── client_entry.ts
│ │ │ │ ├── client_snapshot.ts
│ │ │ │ ├── deno.ts
│ │ │ │ ├── dev_server.ts
│ │ │ │ ├── patches/
│ │ │ │ │ ├── code_eval.ts
│ │ │ │ │ ├── code_eval_test.ts
│ │ │ │ │ ├── commonjs.ts
│ │ │ │ │ ├── commonjs_test.ts
│ │ │ │ │ ├── http_absolute.ts
│ │ │ │ │ ├── http_absolute_test.ts
│ │ │ │ │ ├── inline_env_vars.ts
│ │ │ │ │ ├── inline_env_vars_test.ts
│ │ │ │ │ ├── jsx_comment.ts
│ │ │ │ │ ├── jsx_comment_test.ts
│ │ │ │ │ ├── remove_polyfills.ts
│ │ │ │ │ └── remove_polyfills_test.ts
│ │ │ │ ├── patches.ts
│ │ │ │ ├── server_entry.ts
│ │ │ │ ├── server_snapshot.ts
│ │ │ │ ├── shims/
│ │ │ │ │ ├── object.entries/
│ │ │ │ │ │ └── index.ts
│ │ │ │ │ └── supports-color/
│ │ │ │ │ └── index.ts
│ │ │ │ ├── shims.ts
│ │ │ │ └── verify_imports.ts
│ │ │ ├── shared.ts
│ │ │ └── utils.ts
│ │ └── tests/
│ │ ├── build_test.ts
│ │ ├── dev_server_test.ts
│ │ ├── fixtures/
│ │ │ ├── deno_global_island/
│ │ │ │ ├── islands/
│ │ │ │ │ └── Foo.tsx
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ ├── deno_global_ssr/
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ ├── island_global_name/
│ │ │ │ ├── deno.json
│ │ │ │ ├── islands/
│ │ │ │ │ └── Map.tsx
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ ├── no_islands/
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ ├── no_routes/
│ │ │ │ ├── main.ts
│ │ │ │ └── vite.config.ts
│ │ │ ├── no_static/
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ ├── node_builtin/
│ │ │ │ ├── islands/
│ │ │ │ │ └── NodeIsland.tsx
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ ├── remote_island/
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ ├── tailwind_app/
│ │ │ │ ├── assets/
│ │ │ │ │ └── style.css
│ │ │ │ ├── client.ts
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ ├── _app.tsx
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ ├── tailwind_no_app/
│ │ │ │ ├── assets/
│ │ │ │ │ └── style.css
│ │ │ │ ├── client.ts
│ │ │ │ ├── main.ts
│ │ │ │ ├── routes/
│ │ │ │ │ └── index.tsx
│ │ │ │ └── vite.config.ts
│ │ │ └── test_files_exclusion/
│ │ │ ├── deno.json
│ │ │ ├── main.ts
│ │ │ ├── routes/
│ │ │ │ ├── foo.test.ts
│ │ │ │ ├── index.tsx
│ │ │ │ └── index_test.tsx
│ │ │ └── vite.config.ts
│ │ └── test_utils.ts
│ └── update/
│ ├── README.md
│ ├── deno.json
│ └── src/
│ ├── mod.ts
│ ├── update.ts
│ ├── update_test.ts
│ └── utils.ts
├── tools/
│ ├── check_docs.ts
│ ├── check_links.ts
│ └── release.ts
├── versions.json
└── www/
├── README.md
├── assets/
│ └── styles.css
├── client.ts
├── components/
│ ├── CodeBlock.tsx
│ ├── CodeWindow.tsx
│ ├── CopyButton.tsx
│ ├── DocsSidebar.tsx
│ ├── FancyLink.tsx
│ ├── FeatureIcons.tsx
│ ├── Footer.tsx
│ ├── Header.tsx
│ ├── Icons.tsx
│ ├── NavigationBar.tsx
│ ├── PageSection.tsx
│ ├── Projects.tsx
│ ├── SideBySide.tsx
│ ├── WaveTank.ts
│ └── homepage/
│ ├── CTA.tsx
│ ├── CodeExampleBox.tsx
│ ├── DemoBox.tsx
│ ├── DenoSection.tsx
│ ├── ExampleArrow.tsx
│ ├── FormsSection.tsx
│ ├── Hero.tsx
│ ├── IslandsSection.tsx
│ ├── PartialsSection.tsx
│ ├── RecipeDemo.tsx
│ ├── RenderingSection.tsx
│ ├── SectionHeading.tsx
│ ├── Simple.tsx
│ └── SocialProof.tsx
├── data/
│ ├── docs.ts
│ └── showcase.json
├── deno.json
├── dev.ts
├── islands/
│ ├── Counter.tsx
│ ├── FormSubmitDemo.tsx
│ ├── LemonBottom.tsx
│ ├── LemonDrop.tsx
│ ├── LemonTop.tsx
│ ├── SearchButton.tsx
│ ├── TableOfContents.tsx
│ ├── ThemeToggle.tsx
│ └── VersionSelect.tsx
├── main.ts
├── main_test.ts
├── routes/
│ ├── _app.tsx
│ ├── _error.tsx
│ ├── _middleware.ts
│ ├── docs/
│ │ ├── [...slug].tsx
│ │ ├── _layout.tsx
│ │ ├── _middleware.ts
│ │ └── index.tsx
│ ├── index.tsx
│ ├── raw.ts
│ ├── recipes/
│ │ ├── _layout.tsx
│ │ ├── _middleware.ts
│ │ ├── lemon-honey-tea.tsx
│ │ ├── lemonade.tsx
│ │ └── lemondrop.tsx
│ ├── showcase-bak.tsx
│ ├── showcase.tsx
│ ├── thanks.tsx
│ └── update.tsx
├── static/
│ ├── docsearch.css
│ ├── google40caa9e535ae39e9.html
│ ├── markdown.css
│ └── prism.css
├── utils/
│ ├── markdown.ts
│ ├── prism.ts
│ ├── screenshot.ts
│ ├── screenshot_test.ts
│ └── state.ts
└── vite.config.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
# Use Unix line endings in all text files.
* text=auto eol=lf
================================================
FILE: .github/CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall
community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or advances of
any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address,
without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at hello@lcas.dev.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of
actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the
community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by
[Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing Guidelines
## Submitting a pull request
First, please be sure to ensure `deno task ok` is run and successfully passes.
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
================================================
FILE: .github/workflows/ci.yml
================================================
name: ci
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
deno: ["v2.x", "canary"]
os: [macOS-latest, windows-latest, ubuntu-latest]
include:
- os: ubuntu-latest
cache_path: ~/.cache/deno/
- os: macos-latest
cache_path: ~/Library/Caches/deno/
- os: windows-latest
cache_path: ~\AppData\Local\deno\
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
cache: true
deno-version: ${{ matrix.deno }}
- name: Install dependencies
run: deno install
- name: Verify formatting
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
run: deno fmt --check
- name: Run linter
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
run: deno lint
- name: Spell-check
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
uses: crate-ci/typos@master
- name: Type check project
run: deno task check:types
- name: Run tests
run: deno task test
- name: Check docs
run: deno task check:docs
- name: Build fresh.deno.dev
if: startsWith(matrix.os, 'ubuntu') && matrix.deno == 'v2.x'
run: deno task build-www
================================================
FILE: .github/workflows/deploy.yml
================================================
name: Deploy
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Install Deno
uses: denoland/setup-deno@v2
with:
cache: true
- name: Run install step
run: "deno install"
- name: Build step
working-directory: ./www
run: "deno task build"
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
# Skip publishing for forks
if: github.repository_owner == 'denoland'
with:
project: "fresh"
entrypoint: "server.js"
root: "./www/_fresh/"
================================================
FILE: .github/workflows/post_publish.yml
================================================
name: post_publish
on:
release:
types: [published]
jobs:
update-dl-version:
name: update dl.deno.land version
runs-on: ubuntu-22.04
if: github.repository == 'denoland/fresh'
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Authenticate with Google Cloud
uses: google-github-actions/auth@v2
with:
project_id: denoland
credentials_json: ${{ secrets.GCP_SA_KEY }}
export_environment_variables: true
create_credentials_file: true
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
with:
project_id: denoland
- name: Upload version file to dl.deno.land
run: |
cat packages/fresh/deno.json | jq -r ".version" > release-latest.txt
gsutil -h "Cache-Control: no-cache" cp release-latest.txt gs://dl.deno.land/fresh/release-latest.txt
================================================
FILE: .github/workflows/publish.yml
================================================
name: Publish JSR
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
# Skip publishing for forks
if: github.repository_owner == 'denoland'
steps:
- uses: actions/checkout@v4
- name: Install Deno
uses: denoland/setup-deno@v2
with:
cache: true
- name: Install dependencies
run: deno install
- name: Publish
run: deno publish
================================================
FILE: .gitignore
================================================
_fresh/
.vite/
vendor/
node_modules/
.docs/
.DS_Store
tmp_*
coverage/
vite-inspect/
.vite-inspect/
demo/dist/
================================================
FILE: .vscode/extensions.json
================================================
{
"recommendations": [
"denoland.vscode-deno"
]
}
================================================
FILE: .vscode/settings.json
================================================
{
"deno.enable": true,
"deno.lint": true,
"deno.codeLens.test": true,
"deno.documentPreloadLimit": 2000,
"editor.formatOnSave": true,
"editor.defaultFormatter": "denoland.vscode-deno",
"[typescriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[javascriptreact]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[javascript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"[markdown]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"css.customData": [
".vscode/tailwind.json"
],
"[json]": {
"editor.defaultFormatter": "denoland.vscode-deno"
}
}
================================================
FILE: .vscode/tailwind.json
================================================
{
"version": 1.1,
"atDirectives": [
{
"name": "@tailwind",
"description": "Use the `@tailwind` directive to insert Tailwind's `base`, `components`, `utilities` and `screens` styles into your CSS.",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#tailwind"
}
]
},
{
"name": "@apply",
"description": "Use the `@apply` directive to inline any existing utility classes into your own custom CSS. This is useful when you find a common utility pattern in your HTML that you’d like to extract to a new component.",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#apply"
}
]
},
{
"name": "@responsive",
"description": "You can generate responsive variants of your own classes by wrapping their definitions in the `@responsive` directive:\n```css\n@responsive {\n .alert {\n background-color: #E53E3E;\n }\n}\n```\n",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#responsive"
}
]
},
{
"name": "@screen",
"description": "The `@screen` directive allows you to create media queries that reference your breakpoints by **name** instead of duplicating their values in your own CSS:\n```css\n@screen sm {\n /* ... */\n}\n```\n…gets transformed into this:\n```css\n@media (min-width: 640px) {\n /* ... */\n}\n```\n",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#screen"
}
]
},
{
"name": "@variants",
"description": "Generate `hover`, `focus`, `active` and other **variants** of your own utilities by wrapping their definitions in the `@variants` directive:\n```css\n@variants hover, focus {\n .btn-brand {\n background-color: #3182CE;\n }\n}\n```\n",
"references": [
{
"name": "Tailwind Documentation",
"url": "https://tailwindcss.com/docs/functions-and-directives#variants"
}
]
}
]
}
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2021-2023 Luca Casonato
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
[Documentation](#-documentation) | [Getting started](#-getting-started) |
[API Reference](https://deno.land/x/fresh?doc)
# fresh
**Fresh** is a next generation web framework, built for speed, reliability, and
simplicity.
Some stand-out features:
- Island based client hydration for maximum interactivity.
- Zero runtime overhead: no JS is shipped to the client by default.
- No configuration necessary.
- TypeScript support out of the box.
- File-system routing à la Next.js.
## 📖 Documentation
The [documentation](https://fresh.deno.dev/docs/introduction) is available on
[fresh.deno.dev](https://fresh.deno.dev/).
## 🚀 Getting started
Install the latest [Deno CLI](https://deno.com/) version.
You can scaffold a new project by running the Fresh init script. To scaffold a
project run the following:
```sh
deno run -Ar jsr:@fresh/init
```
Then navigate to the newly created project folder:
```
cd fresh-project
```
From within your project folder, start the development server using the
`deno task` command:
```
deno task dev
```
Now open http://localhost:5173 in your browser to view the page. You make
changes to the project source code and see them reflected in your browser.
To deploy the project to the live internet, you can use
[Deno Deploy](https://deno.com/deploy):
1. Push your project to GitHub.
2. [Create a Deno Deploy project.](https://console.deno.com/new)
3. Select your GitHub repository.
4. The project will be deployed to a public $project.$username.deno.net
subdomain with no configuration necessary.
For a more in-depth getting started guide, visit the
[Getting Started](https://fresh.deno.dev/docs/getting-started) page in the Fresh
docs.
## Contributing
We appreciate your help! To contribute, please read our
[contributing guideline](./.github/CONTRIBUTING.md).
## Adding your project to the showcase
If you feel that your project would be helpful to other Fresh users, please
consider putting your project on the
[showcase](https://fresh.deno.dev/showcase). However, websites that are just for
promotional purposes may not be listed.
To take a screenshot, run the following command.
```sh
deno task screenshot [url] [your-app-name]
```
Then add your site to
[showcase.json](https://github.com/denoland/fresh/blob/main/www/data/showcase.json),
preferably with source code on GitHub, but not required.
## Badges

```md
[](https://fresh.deno.dev)
```
```html
```

```md
[](https://fresh.deno.dev)
```
```html
```
## Hashtags
Use the following hashtags in your social media posts that reference Fresh and
as Topics in the About section of your GitHub repos that contain Fresh code. It
will assure maximum visibility for your posts and code, and promote Fresh
development ecosystem visibility.
- #denofresh
- #deno
Github repo Topics will not include the hash symbol.
================================================
FILE: _typos.toml
================================================
[files]
extend-exclude = [
"packages/fresh/tests/fixture_partials/routes/scroll_restoration/index.tsx",
"www/static/fonts/FixelVariable.woff2",
"www/static/fonts/FixelVariableItalic.woff2",
"packages/fresh/tests/lorem_ipsum.txt",
]
[default]
extend-ignore-identifiers-re = ["Fixel"]
================================================
FILE: deno.json
================================================
{
"vendor": true,
"nodeModulesDir": "manual",
"workspace": [
"./packages/*",
"./www"
],
"tasks": {
"demo": "deno task --cwd=packages/plugin-vite demo",
"demo:build": "deno task --cwd=packages/plugin-vite demo:build",
"demo:start": "deno task --cwd=packages/plugin-vite demo:start",
"test": "deno test -A --parallel",
"www": "deno task --cwd=www dev",
"build-www": "deno task --cwd=www build",
"screenshot": "deno run -A www/utils/screenshot.ts",
"check:types": "deno check --allow-import",
"check:docs": "deno run -A tools/check_docs.ts",
"ok": "deno fmt --check && deno lint && deno task check:types && deno task test",
"test:www": "deno test -A www/main_test.*",
"release": "deno run -A tools/release.ts"
},
"exclude": [
"**/_fresh/*",
"**/tmp/*",
"*/tests_OLD/**",
"**/vite.config.ts.*",
"*/vite.config.ts.*",
"vite.config.ts.*"
],
"publish": {
"include": [
"src/**",
"deno.json",
"README.md",
"LICENSE",
"www/static/fresh-badge.svg",
"www/static/fresh-badge-dark.svg",
"*.todo"
],
"exclude": ["**/*_test.*", "src/__OLD/**", "*.todo", "**/tests/**"]
},
"imports": {
"@deno/doc": "jsr:@deno/doc@^0.172.0",
"@deno/esbuild-plugin": "jsr:@deno/esbuild-plugin@^1.2.0",
"@fresh/build-id": "jsr:@fresh/build-id@^1.0.0",
"@std/cli": "jsr:@std/cli@^1.0.19",
"@std/collections": "jsr:@std/collections@^1.1.2",
"@std/dotenv": "jsr:@std/dotenv@^0.225.5",
"@std/http": "jsr:@std/http@^1.0.15",
"@std/uuid": "jsr:@std/uuid@^1.0.7",
"@supabase/postgrest-js": "npm:@supabase/postgrest-js@^1.21.4",
"@types/mime-db": "npm:@types/mime-db@^1.43.6",
"@types/node": "npm:@types/node@^24.3.0",
"@types/pg": "npm:@types/pg@^8.15.5",
"@types/prismjs": "npm:@types/prismjs@^1.26.5",
"docsearch": "https://esm.sh/@docsearch/js@3.5.2?target=es2020",
"esbuild": "npm:esbuild@0.25.7",
"esbuild-wasm": "npm:esbuild-wasm@0.25.7",
"fresh": "jsr:@fresh/core@^2.0.0",
"mime-db": "npm:mime-db@^1.54.0",
"preact": "npm:preact@^10.28.2",
"preact-render-to-string": "npm:preact-render-to-string@^6.6.5",
"$ga4": "https://raw.githubusercontent.com/denoland/ga4/main/mod.ts",
"@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
"@preact/signals": "npm:@preact/signals@^2.5.1",
"@std/encoding": "jsr:@std/encoding@1",
"@std/fmt": "jsr:@std/fmt@^1.0.7",
"@std/fs": "jsr:@std/fs@1",
"@std/html": "jsr:@std/html@1",
"@std/jsonc": "jsr:@std/jsonc@1",
"@std/media-types": "jsr:@std/media-types@1",
"@std/path": "jsr:@std/path@1",
"@std/semver": "jsr:@std/semver@1",
"@std/streams": "jsr:@std/streams@1",
"@astral/astral": "jsr:@astral/astral@^0.5.5",
"@marvinh-test/fresh-island": "jsr:@marvinh-test/fresh-island@^0.0.3",
"linkedom": "npm:linkedom@^0.18.10",
"@std/async": "jsr:@std/async@^1.0.13",
"@std/expect": "jsr:@std/expect@^1.0.16",
"@std/testing": "jsr:@std/testing@^1.0.12",
"@tailwindcss/postcss": "npm:@tailwindcss/postcss@^4.1.10",
"redis": "npm:redis@^5.8.2",
"rollup": "npm:rollup@^4.55.1",
"tailwindcss": "npm:tailwindcss@^4.1.10",
"postcss": "npm:postcss@8.5.6",
"ts-morph": "npm:ts-morph@^26.0.0",
"@std/front-matter": "jsr:@std/front-matter@^1.0.5",
"github-slugger": "npm:github-slugger@^2.0.0",
"imagescript": "https://deno.land/x/imagescript@1.3.0/mod.ts",
"marked": "npm:marked@^15.0.11",
"marked-mangle": "npm:marked-mangle@^1.1.9",
"prismjs": "npm:prismjs@^1.29.0",
"vite": "npm:vite@^7.3.1"
},
"compilerOptions": {
"lib": ["dom", "dom.asynciterable", "deno.ns", "deno.unstable"],
"jsx": "precompile",
"jsxImportSource": "preact",
"jsxPrecompileSkipElements": [
"a",
"img",
"source",
"body",
"html",
"head",
"title",
"meta",
"script",
"link",
"style",
"base",
"noscript",
"template"
],
"types": ["vite/client"]
},
"lint": {
"rules": {
"tags": ["recommended", "fresh", "jsr", "jsx", "react"],
"exclude": ["no-window"],
"include": ["no-console"]
}
},
"fmt": {
"exclude": ["./www/static/**/*.svg"]
}
}
================================================
FILE: docs/1.x/concepts/ahead-of-time-builds.md
================================================
---
description: |
Fresh optimize assets ahead of time, which makes pages load way quicker.
---
Fresh enables you to pre-optimize frontend assets before the code is deployed.
During that process the code for Islands will be compressed and optimized, so
that Fresh can send as little code as possible to the browser. Depending on the
amount of code an island needs, this process can take several seconds if done on
the fly server-side.
Doing those optimizations ahead-of-time and deploying the already optimized
assets alongside with your code, allows Fresh to treat them as like any other
static file and can serve it immediately without any further processing. On
pages with islands, having to do no processing greatly speeds up page load
times.
Plugins can build static assets during ahead-of-time builds. This can be used to
pre-process or generate CSS files, for example.
## Creating an optimized build
To have Fresh optimize all the assets, run one of the following commands:
```sh Terminal
# As a task in newer Fresh projects
deno task build
# or invoke it manually
deno run -A dev.ts build
```
This will create a `_fresh` folder in the project directory. That folder
contains the optimized assets and a `snapshot.json` file which includes some
metadata for Fresh.
Any other static files generated by plugins will be stored in the
`_fresh/static` subfolder. They will be served the same as other
[static files](/docs/1.x/concepts/static-files.md).
> [info]: The `_fresh` folder should not be committed to the repository. Add an
> entry in the `.gitignore` file to ensure that it is not committed. Create that
> file at the root of your git repository if not present.
>
> ```gitignore .gitignore
> # Ignore fresh build directory
> _fresh/
> ```
## Running Fresh with optimized assets
When Fresh is started in non-development mode (usually via `main.ts`), Fresh
will automatically pick up optimized assets when a `_fresh` folder exists. If
found, Fresh will print the following message to the terminal:
```sh Terminal output
Using snapshot found at /path/to/project/_fresh
```
## Deploying an optimized Fresh project
If you are deploying a Fresh project to Deno Deploy, you can use ahead-of-time
builds to optimize the assets before deploying them. This will make your
application load quicker.
Open the Deno Deploy dashboard for your project and head to the "Git
Integration" section in the project settings. Enter `deno task build` in the
"Build command" field and save. This will switch your Deno Deploy project to use
ahead-of-time builds.
## Migrating existing projects with Plugins
If you're using Fresh plugins, extract them into a `fresh.config.ts` file, so
that both the `dev.ts` and `main.ts` script have access to them.
```ts fresh.config.ts
import { defineConfig } from "$fresh/server.ts";
import twindPlugin from "$fresh/plugins/twind.ts";
import twindConfig from "./twind.config.ts";
export default defineConfig({
plugins: [twindPlugin(twindConfig)],
});
```
```ts main.ts
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import config from "./fresh.config.ts";
await start(manifest, config);
```
```ts dev.ts
import dev from "$fresh/dev.ts";
import config from "./fresh.config.ts";
await dev(import.meta.url, "./main.ts", config);
```
================================================
FILE: docs/1.x/concepts/app-wrapper.md
================================================
---
description: |
Add a global app wrapper to provide common meta tags or context for application routes.
---
An app wrapper is defined in an `_app.tsx` file in `routes/` folder and is
typically used to create the outer structure of an HTML document. It must
contain a default export that is a regular Preact component. Only one such
wrapper is allowed per application.
The component to be wrapped is received via props, in addition to a few other
things. This allows for the introduction of a global container functioning as a
template which can be conditioned based on state and params. Note that any state
set by middleware is available via `props.state`.
```tsx routes/_app.tsx
import { PageProps } from "$fresh/server.ts";
export default function App({ Component, state }: PageProps) {
// do something with state here
return (
{props.data.stars} stars
{project.stars} stars
404 not found: {url.pathname}
; } ``` #### Manually render 404 pages The `_404.tsx` file will be invoked automatically when no route matches the URL. In some cases, one needs to manually trigger the rendering of the 404 page, for example when the route did match, but the requested resource does not exist. This can be achieved with `ctx.renderNotFound`. ```tsx routes/blog/[slug].tsx import { Handlers, PageProps } from "$fresh/server.ts"; export const handler: Handlers = { async GET(req, ctx) { const blogpost = await fetchBlogpost(ctx.params.slug); if (!blogpost) { return ctx.renderNotFound({ custom: "prop", }); } return ctx.render({ blogpost }); }, }; export default function BlogpostPage({ data }) { return (500 internal error: {(error as Error).message}
; } ``` ================================================ FILE: docs/1.x/concepts/forms.md ================================================ --- description: | Robustly handle user inputs using HTML ` > ); } ``` When the user submits the form, Deno will retrieve the `email` value using the request's `formData()` method, add the email to a list, and redirect the user to a thank you page. ## Handling file uploads File uploads can be handled in a very similar manner to the example above. Note that this time, we have to explicitly declare the form's encoding to be `multipart/form-data`. ```tsx routes/subscribe.tsx import { Handlers, type PageProps } from "$fresh/server.ts"; interface Props { message: string | null; } export const handler: Handlers{message}
: null} > ); } ``` ## A note of caution These examples are simplified to demonstrate how Deno and Fresh handle HTTP requests. In the Real World™, you'll want to validate your data (_especially the file type_) and protect against cross-site request forgery. Consider yourself warned. ================================================ FILE: docs/1.x/concepts/index.md ================================================ --- description: | This chapter goes over some fundamental concepts of Fresh. --- This chapter goes over some fundamental concepts of Fresh. It covers the overarching architecture design of Fresh applications, as well as reference documentation about the various features of Fresh. ================================================ FILE: docs/1.x/concepts/islands.md ================================================ --- description: | Islands enable client side interactivity in Fresh. They are hydrated on the client in addition to being rendered on the server. --- Islands enable client side interactivity in Fresh. Islands are isolated Preact components that are rendered on the server and then hydrated on the client. This is different from all other components in Fresh, as they are usually rendered on the server only. Islands are defined by creating a file in the `islands/` folder in a Fresh project. The name of this file must be a PascalCase or kebab-case name of the island. ```tsx islands/my-island.tsx import { useSignal } from "@preact/signals"; export default function MyIsland() { const count = useSignal(0); return (This text is rendered on the server
This text is rendered on the server
String from props: {foo}
{" "} number is: {number}.
Some more server rendered text
{data.greeting}
{data.greeting}
Hello world
; } ``` You can skip already inherited layouts inside a layout file: ```tsx routes/special/_layout.tsx import { LayoutConfig } from "$fresh/server.ts"; export const config: LayoutConfig = { skipInheritedLayouts: true, // Skip already inherited layouts }; export default function MyPage() { returnHello world
; } ``` ================================================ FILE: docs/1.x/concepts/middleware.md ================================================ --- description: | Add middleware routes to intercept requests or responses for analytics purposes, access control, or anything else. --- A middleware is defined in a `_middleware.ts` file. It will intercept the request in order for you to perform custom logic before or after the route handler. This allows modifying or checking requests and responses. Common use-cases for this are logging, authentication, and performance monitoring. Each middleware gets passed a `next` function in the context argument that is used to trigger child handlers. The `ctx` also has a `state` property that can be used to pass arbitrary data to downstream (or upstream) handlers. This `state` is included in `PageProps` by default, which is available to both the special [\_app](/docs/1.x/concepts/app-wrapper.md) wrapper and normal [routes](/docs/1.x/concepts/routes.md). `ctx.state` is normally set by modifying its properties, e.g. `ctx.state.loggedIn = true`, but you can also replace the entire object like `ctx.state = { loggedIn: true }`. ```ts routes/_middleware.ts import { FreshContext } from "$fresh/server.ts"; interface State { data: string; } export async function handler( req: Request, ctx: FreshContext{count.value}
);
}
================================================
FILE: www/components/CodeWindow.tsx
================================================
import type { JSX } from "preact";
interface CodeWindowProps extends JSX.HTMLAttributes
Jump right in and build your website with Fresh. Learn everything you need to know in seconds.
Deno is the next evolution of server-side JavaScript, with stronger security, a robust built-in toolchain, and zero-config TypeScript support. (It's faster than Node, too.)
Don't fight the browser. Fresh helps you handle form submissions and other dynamic requests server-side, from any route.
Since Fresh is built on{" "} Deno, it's built on web standards.
{props.code}
The server supplied the initial value of {props.start}.
Fresh ships plain HTML to the client, then hydrates with JavaScript only where needed.
Because it's Preact, you get best-in-class performance, plus the convenience of{" "} Signals .
Fresh Partials let you fetch HTML and slot it directly into the page, without a full page reload—perfect for interactive elements and dynamic apps.
Freshly server-rendered {time}
); }`; export function RenderingSection() { return (Fresh routes are dynamically server-rendered{" "} Preact{" "} components, so there's zero JavaScript shipped to the browser by default.
Simple to write; fast to run.
Freshly server-rendered {new Date().toLocaleString("default", { dateStyle: "medium", timeStyle: "medium", })} UTC
Introducing Fresh:
Fresh is designed to be easy to use by building on the best well-known tools, conventions, and web standards.
Fresh is the secret sauce behind production-grade, enterprise-ready software like{" "} Deco.cx, Brazil's top eCommerce platform
“ The team also used{" "} Fresh, a next-gen Deno-native full stack web framework that sends zero JavaScript to the client, for its modern developer experience and snappy performance…
This stack unlocked{" "} 5x faster page load speeds and a 30% jump in conversion rates {" "} for their clients. ”
The server supplied the initial value of 3.
This route is used only for demo purposes;{" "} see the home page.
You can add these stylish badges to your project’s README to show that it was built with Fresh.
Below is a selection of projects that have been built with Fresh.{" "} Add yours!
You can add these stylish badges to your project’s README to show that it was built with Fresh.
Below is a selection of projects that have been built with Fresh.{" "} Add yours!
That was all handled server-side, with{" "} no client-side JavaScript! Nifty, huh?
…Anyway, you probably want to{" "} go back now.
Back${escapeHtml(text)}`;
} else {
const html = Prism.highlight(text, grammar, lang);
out +=
`${html}`;
}
out += `\n${icon}${ label[type] }${this.parser.parse(tokens)}\n`; } return `
\n${this.parser.parse(tokens)}\n`; } #assert(expr: unknown, msg: string): asserts expr { if (!expr) throw new Error(msg); } } export interface MarkdownOptions { inline?: boolean; } export function renderMarkdown( input: string, opts: MarkdownOptions = {}, ): { headings: MarkdownHeading[]; html: string } { const renderer = new DefaultRenderer(); const markedOpts: Marked.MarkedOptions & { async: false } = { gfm: true, async: false, renderer, }; try { const html = opts.inline ? Marked.parseInline(input, markedOpts) : Marked.parse(input, markedOpts); return { headings: renderer.headings, html }; } catch (err) { throw new HttpError(500, "Markdown parsing error", { cause: err, }); } } ================================================ FILE: www/utils/prism.ts ================================================ import Prism from "prismjs"; import "prismjs/components/prism-jsx.js"; import "prismjs/components/prism-typescript.js"; import "prismjs/components/prism-tsx.js"; import "prismjs/components/prism-diff.js"; import "prismjs/components/prism-json.js"; import "prismjs/components/prism-bash.js"; import "prismjs/components/prism-yaml.js"; import "prismjs/components/prism-ignore.js"; // deno-lint-ignore no-explicit-any const languages = Prism.languages as any; /** Extends `sh` with `deno` as a function token in Shell/Bash languages */ languages.sh.deno = { pattern: /(^|[\s;|&]|[<>]\()(?:deno)(?=$|[)\s;|&])/, lookbehind: true, alias: "function", }; languages.bash.deno = languages.sh.deno; /** * Adds `txt-files` language for file-structure code blocks. * * - Comments: Makes `#` and everything after a comment * - Operator: Matches the file structure symbols like `├──`, `└──`, and `│ ` * - Root: Matches `