@sveltejs/adapter-netlify 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +3 -105
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,113 +2,11 @@
2
2
 
3
3
  A SvelteKit adapter that creates a Netlify app.
4
4
 
5
- If you're using [adapter-auto](../adapter-auto), you don't need to install this unless you need to specify Netlify-specific options, since it's already included.
5
+ If you're using [adapter-auto](https://kit.svelte.dev/docs/adapter-auto), you don't need to install this unless you need to specify Netlify-specific options, since it's already included.
6
6
 
7
- ## Installation
7
+ ## Docs
8
8
 
9
- ```bash
10
- npm i -D @sveltejs/adapter-netlify
11
- ```
12
-
13
- You can then configure it inside of `svelte.config.js`:
14
-
15
- ```js
16
- import adapter from '@sveltejs/adapter-netlify';
17
-
18
- export default {
19
- kit: {
20
- // default options are shown
21
- adapter: adapter({
22
- // if true, will create a Netlify Edge Function rather
23
- // than using standard Node-based functions
24
- edge: false,
25
-
26
- // if true, will split your app into multiple functions
27
- // instead of creating a single one for the entire app.
28
- // if `edge` is true, this option cannot be used
29
- split: false
30
- })
31
- }
32
- };
33
- ```
34
-
35
- Then, make sure you have a [netlify.toml](https://docs.netlify.com/configure-builds/file-based-configuration) file in the project root. This will determine where to write static assets based on the `build.publish` settings, as per this sample configuration:
36
-
37
- ```toml
38
- [build]
39
- command = "npm run build"
40
- publish = "build"
41
- ```
42
-
43
- If the `netlify.toml` file or the `build.publish` value is missing, a default value of `"build"` will be used. Note that if you have set the publish directory in the Netlify UI to something else then you will need to set it in `netlify.toml` too, or use the default value of `"build"`.
44
-
45
- ### Node version
46
-
47
- New projects will use Node 16 by default. However, if you're upgrading a project you created a while ago it may be stuck on an older version. See [the Netlify docs](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript) for details on manually specifying Node 16 or newer.
48
-
49
- ## Netlify Edge Functions (beta)
50
-
51
- SvelteKit supports the beta release of [Netlify Edge Functions](https://docs.netlify.com/netlify-labs/experimental-features/edge-functions/). If you pass the option `edge: true` to the `adapter` function, server-side rendering will happen in a Deno-based edge function that's deployed close to the site visitor. If set to `false` (the default), the site will deploy to standard Node-based Netlify Functions.
52
-
53
- ```js
54
- import adapter from '@sveltejs/adapter-netlify';
55
-
56
- export default {
57
- kit: {
58
- adapter: adapter({
59
- // will create a Netlify Edge Function using Deno-based
60
- // rather than using standard Node-based functions
61
- edge: true
62
- })
63
- }
64
- };
65
- ```
66
-
67
- ## Netlify alternatives to SvelteKit functionality
68
-
69
- You may build your app using functionality provided directly by SvelteKit without relying on any Netlify functionality. Using the SvelteKit versions of these features will allow them to be used in dev mode, tested with integration tests, and to work with other adapters should you ever decide to switch away from Netlify. However, in some scenarios you may find it beneficial to use the Netlify versions of these features. One example would be if you're migrating an app that's already hosted on Netlify to SvelteKit.
70
-
71
- ### Using Netlify Redirect Rules
72
-
73
- During compilation, redirect rules are automatically appended to your `_redirects` file. (If it doesn't exist yet, it will be created.) That means:
74
-
75
- - `[[redirects]]` in `netlify.toml` will never match as `_redirects` has a [higher priority](https://docs.netlify.com/routing/redirects/#rule-processing-order). So always put your rules in the [`_redirects` file](https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file).
76
- - `_redirects` shouldn't have any custom "catch all" rules such as `/* /foobar/:splat`. Otherwise the automatically appended rule will never be applied as Netlify is only processing [the first matching rule](https://docs.netlify.com/routing/redirects/#rule-processing-order).
77
-
78
- ### Using Netlify Forms
79
-
80
- 1. Create your Netlify HTML form as described [here](https://docs.netlify.com/forms/setup/#html-forms), e.g. as `/routes/contact.svelte`. (Don't forget to add the hidden `form-name` input element!)
81
- 2. Netlify's build bot parses your HTML files at deploy time, which means your form must be [prerendered](https://kit.svelte.dev/docs/page-options#prerender) as HTML. You can either add `export const prerender = true` to your `contact.svelte` to prerender just that page or set the `kit.prerender.force: true` option to prerender all pages.
82
- 3. If your Netlify form has a [custom success message](https://docs.netlify.com/forms/setup/#success-messages) like `<form netlify ... action="/success">` then ensure the corresponding `/routes/success.svelte` exists and is prerendered.
83
-
84
- ### Using Netlify Functions
85
-
86
- With this adapter, SvelteKit endpoints are hosted as [Netlify Functions](https://docs.netlify.com/functions/overview/). Netlify function handlers have additional context, including [Netlify Identity](https://docs.netlify.com/visitor-access/identity/) information. You can access this context via the `event.platform.context` field inside your hooks and `+page.server` or `+layout.server` endpoints. These are [serverless functions](https://docs.netlify.com/functions/overview/) when the `edge` property is `false` in the adapter config or [edge functions](https://docs.netlify.com/edge-functions/overview/#app) when it is `true`.
87
-
88
- ```js
89
- // +page.server.js
90
- export const load = async (event) => {
91
- const context = event.platform.context;
92
- console.log(context); // shows up in your functions log in the Netlify app
93
- };
94
- ```
95
-
96
- Additionally, you can add your own Netlify functions by creating a directory for them and adding the configuration to your `netlify.toml` file. For example:
97
-
98
- ```toml
99
- [build]
100
- command = "npm run build"
101
- publish = "build"
102
-
103
- [functions]
104
- directory = "functions"
105
- ```
106
-
107
- ## Troubleshooting
108
-
109
- ### Accessing the file system
110
-
111
- You can't access the file system through methods like `fs.readFileSync` in Serverless/Edge environments. If you need to access files that way, do that during building the app through [prerendering](https://kit.svelte.dev/docs/page-options#prerender). If you have a blog for example and don't want to manage your content through a CMS, then you need to prerender the content (or prerender the endpoint from which you get it) and redeploy your blog everytime you add new content.
9
+ [Docs](https://kit.svelte.dev/docs/adapter-netlify)
112
10
 
113
11
  ## Changelog
114
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-netlify",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -38,7 +38,7 @@
38
38
  "rollup": "^3.7.0",
39
39
  "typescript": "^4.9.4",
40
40
  "uvu": "^0.5.6",
41
- "@sveltejs/kit": "^1.1.1"
41
+ "@sveltejs/kit": "^1.1.3"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@sveltejs/kit": "^1.0.0"