# Serving files

The utilities component `@stricjs/utils` provides 2 ways to serve static files.

### Searching

Use the `stream` method to create a function to search for files based on the request pathname.

```typescript
import { stream } from '@stricjs/utils';

// Dynamically search for files in the directory
export default { fetch: stream('public'); }; 
```

### Grouping

Use the `group` method to create a router group that handle each file as a route.

```typescript
import { Router } from '@stricjs/router';
import { group } from '@stricjs/utils';

// Register each file handler as a route
export default new Router().plug(group('public'));
```

This method is way faster than file searching but with drawbacks:

* Files shouldn't be deleted.
* More files can't be added after running.
* High memory usage if you have many files.
